I am building my first application, and have a couple of quick questions. Hopefully someone can point me in the right direction. 1. When I created my model , I noticed a field named "created_at" , which comes in handy. But when I retrieve the value , it comes back very long and un-user friendly. How do I return this date as: Jun 23 08 , or March 21, 2008 , etc? 2. In my layout , I have some simple CSS which formats some tabs ( li''s ). If we are on a certain page , I would add "class = current" to make the tab background a different color. How do I differentiate which page I am on , so I can add the class current to the proper page? Thanks! Glad to be on board. JT --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
JT, 1. Look through strftime at http://ruby-doc.org/core/classes/Time.html#M000297 e.g: created_at.strfime(''%B %d'') == ''January 01'' 2. controller.controller_name and controller.action_name give you the current controller and action in a view. Here''s some ideas on tab helpers: http://www.therailsway.com/2007/6/4/free-for-all-tab-helper http://www.therailsway.com/2007/6/28/free-for-all-tab-helper-summary On Aug 26, 5:52 pm, trope <jtrope...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am building my first application, and have a couple of quick > questions. Hopefully someone can point me in the right direction. > > 1. When I created my model , I noticed a field named "created_at" , > which comes in handy. But when I retrieve the value , it comes back > very long and un-user friendly. How do I return this date as: Jun 23 > 08 , or March 21, 2008 , etc? > > 2. In my layout , I have some simple CSS which formats some tabs > ( li''s ). If we are on a certain page , I would add "class = current" > to make the tab background a different color. How do I differentiate > which page I am on , so I can add the class current to the proper > page? > > Thanks! Glad to be on board. > > JT--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Tue, Aug 26, 2008 at 7:52 PM, trope <jtropeano-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I am building my first application, and have a couple of quick > questions. Hopefully someone can point me in the right direction. > > 1. When I created my model , I noticed a field named "created_at" , > which comes in handy. But when I retrieve the value , it comes back > very long and un-user friendly. How do I return this date as: Jun 23 > 08 , or March 21, 2008 , etc?strftime is your answer http://ruby-doc.org/core/classes/Time.html#M000297 Make sure to set your time zone in environment.rb> > > 2. In my layout , I have some simple CSS which formats some tabs > ( li''s ). If we are on a certain page , I would add "class = current" > to make the tab background a different color. How do I differentiate > which page I am on , so I can add the class current to the proper > page?In your controller set an instance variable such as: @css_class = "class = current" Use it in your page as: <%= @css_class %>> > > Thanks! Glad to be on board. > > JT > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
There''s also params[:controller] and params[:action] that do the same thing as controller.controller_name and controller.action_name respectively. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---