Partial view in rails layput -
i want render partial in layout page i.e. application.html.erb , variable it. created partial view in layouts folder "_fellowshi_sider.html.erb" , added below code in application.html.erb
<%= render "layouts/fellowship_sider", :entries => @entries %> i not able understand set value @entries variable. wrote function in application_controller doesn't work.
if partial in layout need @entries object on every call check method in application controller being called, before filter in controller every action.
application controller:
class applicationcontroller < actioncontroller::base before_filter :get_entries def get_entries @entries = entry.all end end after doing don't need pass @entries variable partial, can access directly in partial view.
layout:
<%= render "layouts/fellowship_sider" %> _fellowship_sider.html.erb:
<% @entries.each |entry| %> <%= entry.foo %> <% end %>
Comments
Post a Comment