2013-01-22 67 views
2

我想使用自定义通知助手在我的Padrino应用程序中生成通知(Flash)消息。助手里面我想使用内置的Padrino佣工(闪光灯和content_tag(见下面的例子)如何在自定义助手类中使用Padrino助手

class NotificationHelper  

    def self.notify 
    unless flash.empty? 
     content_tag :div, class: 'notifications' do 
     flash.map do |key, msg| 
      headline = case key 
      when :success then 'Super!' 
      when :error then 'Oh. Das tut uns leid.' 
      end 
      content_tag :p, :class => "notification" do 
      content_tag(:span, headline, class: "headline #{key}") + msg 
      end 
     end.join("\n") 
     end 
    end 
    end 
end 

但是,如果我用我的意见帮助,我得到了以下错误: “ NoMethodError - 未定义的方法`content_tag”的NotificationHelper:类:”

我干了什么错

回答

相关问题