Hi, I am using Ruby on Rails to create a new site. On every page, I want to have a log in box. I also want to display the latest 5 news items on all the pages as well. How could I go around this? Is it possible to have @news News.find(:all, :limit => 5 ) in the application handler, and then call the @news on all pages? Would I also be able to handle the log in code in the main application controller aswell? Thanks a lot, Rob -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
take a look at learningrails.com they have some excellent videos on creating an app with the login functionality Ryan Bates also has great screencasts on almost every topic to get you up and running railscasts.com jason On Fri, Dec 19, 2008 at 12:06 PM, Rob Pa <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote:> > Hi, > > I am using Ruby on Rails to create a new site. > > On every page, I want to have a log in box. I also want to display the > latest 5 news items on all the pages as well. > > How could I go around this? Is it possible to have @news > News.find(:all, :limit => 5 ) in the application handler, and then call > the @news on all pages? > > Would I also be able to handle the log in code in the main application > controller aswell? > > Thanks a lot, > Rob > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 19, 1:06 pm, Rob Pa <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > I am using Ruby on Rails to create a new site. > > On every page, I want to have a log in box. I also want to display the > latest 5 news items on all the pages as well. > > How could I go around this?You would probably want to put these elements in your layout, rather than in each individual view.> Is it possible to have @news > News.find(:all, :limit => 5 ) in the application handler, and then call > the @news on all pages?You could do this, but it would probably be easier and more maintainable to use a partial.> > Would I also be able to handle the log in code in the main application > controller aswell?Yes. See restful_authentication for a very nice login plugin (I use it on most of my apps).> > Thanks a lot, > RobBest, -- Marnen Laibow-Koser marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org http://www.marnen.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Rob, Partials sounds the go to me ! cheers Dave On Dec 20, 3:06 am, Rob Pa <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > I am using Ruby on Rails to create a new site. > > On every page, I want to have a log in box. I also want to display the > latest 5 news items on all the pages as well. > > How could I go around this? Is it possible to have @news > News.find(:all, :limit => 5 ) in the application handler, and then call > the @news on all pages? > > Would I also be able to handle the log in code in the main application > controller aswell? > > Thanks a lot, > Rob > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---