Rails: Displaying pages navigation inside application layout -
i'm trying display page navigation rails in addiction page_title outputs record's informations inside brackets this:
- [#<page id: 1, page_title: "about", page_content: "about page content", created_at: "2013-05-04 06:38:03", updated_at: "2013-05-04 06:38:03">] - other page [#....etc...]
how can fix this? thx.
application.html.erb
<li> <%= @pages.each |p| %> <%= link_to page_path(p.id) %> <%= p.page_title %> <% end %> <% end %> </li>
application_controller.rb
class applicationcontroller < actioncontroller::base protect_from_forgery before_filter :set_layout_variables def set_layout_variables @pages = page.all end end
remove =
in line <%= @pages.each |p| %>
it should be
<li> <% @pages.each |p| %> <%= link_to page_path(p.id) %> <%= p.page_title %> <% end %> <% end %> </li>
<%=
output result of line (in case, loop), displays page record. that's why see record in output.
Comments
Post a Comment