Rendering Partial

I am a bit confused when coming from layout and partials.

To start of I have a file called application.html.erb which has my
layout such has follow

<html>
<head>
<body>
<%= render 'layouts/footer' %>
</body
</html>

This call a new file _footer.html.erb
This file his has follow
<footer class="footer">
  <nav>
        <%= render "pages/link" %>
  <ol class="footer_pages">

  </ol>
  </nav>
</footer>
Which calls a partial in the folder Pages which his a resources and has
_link.html.erb and contains the follow
<li>
  <%= @pages.each do |page| %>
    <%= page.name %>
  <% end %>
</li>

Now the issues is @pages.each his nil and I understand the caller will
initiate the @pages = Page.all but the caller is who??

I try application and inserting it and doesnt see it, What i am doing
wrong?

You have to setup @pages in the controller action. Also have a look
at the Rails Guide on Layouts and Rendering (I seem to remember
suggesting this before), section 3.4.4 details how to pass local
variables to partials. But read and understand the rest also.

Have you finished working through railstutorial.org yet? I strongly
suggest working through that before doing more on your own app. I
seem to remember suggesting that before also.

Colin

Colin Law wrote in post #1069337:

</html>
</footer>

I try application and inserting it and doesnt see it, What i am doing
wrong?

You have to setup @pages in the controller action. Also have a look
at the Rails Guide on Layouts and Rendering (I seem to remember
suggesting this before), section 3.4.4 details how to pass local
variables to partials. But read and understand the rest also.

Have you finished working through railstutorial.org yet? I strongly
suggest working through that before doing more on your own app. I
seem to remember suggesting that before also.

Colin

Yeah I have read it, understood at 100% that where i am confused i
probably understood 90% this is the last 10% of it. I did set it up in
the controller action of which one

- controller/application -- prob with this is there is no action define
- controller/pages -- in which actions, i try show, index doesn't see it
- controller/customer -- don't even understand why it would be in
customer
- controller/sessions -- same has customer irrelevant it because i am
calling from the footer which is located in the application

Colin Law wrote in post #1069337:

</html>
</footer>

I try application and inserting it and doesnt see it, What i am doing
wrong?

You have to setup @pages in the controller action. Also have a look
at the Rails Guide on Layouts and Rendering (I seem to remember
suggesting this before), section 3.4.4 details how to pass local
variables to partials. But read and understand the rest also.

Have you finished working through railstutorial.org yet? I strongly
suggest working through that before doing more on your own app. I
seem to remember suggesting that before also.

Colin

Yeah I have read it, understood at 100% that where i am confused i
probably understood 90% this is the last 10% of it. I did set it up in
the controller action of which one

- controller/application -- prob with this is there is no action define
- controller/pages -- in which actions, i try show, index doesn't see it
- controller/customer -- don't even understand why it would be in
customer
- controller/sessions -- same has customer irrelevant it because i am
calling from the footer which is located in the application

I am sorry but it is clear you have not grasped some of the basics of
the way Rails works with regards to actions and views. Have you
really worked right through railstutorial.org? If so then I think you
need to go back to the beginning and start again, making sure you
understand every concept and every line of code.

Colin

Colin Law wrote in post #1069341:

I am sorry but it is clear you have not grasped some of the basics of
the way Rails works with regards to actions and views.

This is what I understood from the tutorial

10.20
<%= render @microposts %> allows you to posts anything that his in the
file _micropost.html.erb

10.21 allows you to show the _micropost.html.erb code which show the
content of a single microposts and time_ago_in_words which his a
function located in the helper module

10.22 his the controller
class UsersController
def show
@microposts = anything that you want such has microposts.all if you
wanted
end
end

It also must be in the UserController because its the caller.

The problem his my application is located in the layouts and calling for
footer in the same folder
If we look in the application folder there is those two lines

class ApplicationController < ActionController::Base
  protect_from_forgery
  include SessionsHelper
end

now what i am thinking to declare the @pages his has follow

class ApplicationController < ActionController::Base
  protect_from_forgery
  include SessionsHelper
  @pages = Page.all
end

but its not been seen. This is how I see it, and if its wrong then i
must of miss something.

Have a look at the Rails Guide on debugging to get ideas on how to
debug your code. I am beginning to sound like a stuck record.

Colin

Colin Law wrote in post #1069349: