Hi Dave.
Have you seen this Railscasts? http://railscasts.com/episodes/31
It might get you started.
Best.
Mike
On Jul 7, 2008, at 6:32 PM, Dave Lynam wrote:
>
> I have an object that holds the date in the form of "Tue Jul 08
> 14:18:00-0700 2008" and I want to only display the time in the format
> of 6:00-8:00 or just 6:00. The controller looks like this:
>
> def show
> @events = Event.find(:all, :conditions => [''date between ?
> and ?'', @date.strftime("%Y-%m") +
''-01'',
> @date.next_month.strftime("%Y-%m") + ''-01''])
> end
>
> I am thinking that I should write a function in the model that changes
> the format of this current object to what I want. Something like
>
> def to_s
> #some code to change the format
> end
>
> and then append this function on the end of the event call like so:
>
> def show
> @events = Event.find(:all, :conditions => [''date between ?
> and ?'', @date.strftime("%Y-%m") +
''-01'',
> @date.next_month.strftime("%Y-%m") +
''-01'']).to_s
> end
>
> but I have no idea if this is the right approach or what code to use
> in the to_s function. Any help is greatly appreciated!
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---