jeudi 5 mars 2015

undefined method `each' for nil:NilClass in rails while using render a action of different controller in application controller

i generate to scaffolds name as header and footers. In application.html.erb I use this code



<%= render template:"headers/index" %>
<%= yield %>
<%= render template:"headers/index" %>


for render action. this is all because of i want to dynamically customize header and footer layout through html_safe method.


I faced error undefined method `each' for nil:NilClass ![enter image description here][1] I know both why this error comes when render a action in another controller and how to solve. but still facing this error just because of not able to define an action for application.html.erb in application.rb


in my applications_controller.rb



before_filter :set_headers
def set_headers
@headers = Header.all
end


how to solve this problem


Aucun commentaire:

Enregistrer un commentaire