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? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 19 July 2012 14:51, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law wrote in post #1069337:> On 19 July 2012 14:51, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> </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. > > ColinYeah 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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 19 July 2012 15:35, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1069337: >> On 19 July 2012 14:51, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> </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 applicationI 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> > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law wrote in post #1069341:> On 19 July 2012 15:35, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 19 July 2012 15:58, Jean-Sébastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1069341: >> On 19 July 2012 15:35, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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.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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law wrote in post #1069349:> On 19 July 2012 15:58, Jean-Sbastien D. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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. > > ColinOk thanks for your help. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Seemingly Similar Threads
- Static Pages from Railcast
- Problem with undefined variable current_user
- Following railstutorial.org tutorial, how to make the microposts be seen by all?
- No route matches [GET] "/microposts/304"
- Action Controller Error: undefined local variable or method `current_user'