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

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

This call a new file _footer.html.erb
This file his has follow

<%= render "pages/link" %>
Which calls a partial in the folder Pages which his a resources and has _link.html.erb and contains the follow
  • <%= @pages.each do |page| %> <%= page.name %> <% end %>
  • 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?

    On 19 July 2012 14:51, Jean-Sbastien D. [email protected] wrote:

    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 L. wrote in post #1069337:

    On 19 July 2012 14:51, Jean-Sbastien D. [email protected] wrote:

    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, did the tutorial and 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

    On 19 July 2012 15:35, Jean-Sbastien D. [email protected] wrote:

    suggesting this before), section 3.4.4 details how to pass local
    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

    On 19 July 2012 15:58, Jean-Sbastien D. [email protected] wrote:

    10.20
    @microposts = anything that you want such has microposts.all if you

    @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 L. wrote in post #1069341:

    On 19 July 2012 15:35, Jean-Sbastien D. [email protected] wrote:

    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.

    Colin L. wrote in post #1069349:

    On 19 July 2012 15:58, Jean-Sbastien D. [email protected] wrote:

    10.20
    @microposts = anything that you want such has microposts.all if you

    @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

    Ok thanks for your help.