I am wondering how can I reach my data in the following situation
I have a resource called Pages, it has all actions possible and was created has Ryan bate proposed on his railscast at http://railscasts.com/episodes/117-semi-static-pages?autoplay=true. Now I have used the layout folder has follow
The page have a permalink and I want them to be in the _footer section so it could be About Us, Term and Condition, etc...
So here what I have done application.html.erb
<%= render 'layouts/header' %> <div class="container"> <% flash.each do |key, value| %> <div class="alert alert-<%= key %>"><%= value %></div> <% end %> <%= yield %> <%= render 'layouts/footer' %> <%= debug(params) if Rails.env.development? %> </div>
Which calls _footer in the layouts folder This is _footer.html.erb
<footer class="footer"> <small> Copyright <%= Time.now.year %> </small> <nav><%= render "pages/link" %> <ol class="footer_pages"> </ol> </nav> </footer>
which call a file in the Pages/_link.html.erb This is the file
<li> <%= @pages.each do |page| %> <%= page.name %> <% end %> </li>
At this points pages.each isn't initialize and doesn't work if i am correct So what i did his initialize @pages = Page.all in the controller applicationController because its the caller. This theory should allow me to read it, but it still doesn't work! What i am doing wrong?
Update since i don't know how to add other comments applicationController
class ApplicationController < ActionController::Base protect_from_forgery include SessionsHelper @pages = Page.all end