[Rails] Re: Accessing datetime elements from hash passed to method
On Aug 6, 7:20 pm, Jarek Plonski <li...@ruby-forum.com> wrote:
> I'm passing hash (called 'params') to a method. Some keys (one of them
> is called 'starts_at') in that hash have date as a value (taken from
> datetime_select helper). I want to access the date elements like date
> only or time only but I'm just out of ideas.
>
> def self.new_meeting(params)
> str = params['starts_at(1i)']
> puts str
> end
>
> This returns nothing.
>
> def self.new_meeting(params)
> str = params[:starts_at]
> puts str
> end
>
> This returns whole date with time.
>
> Ruby 1.9.2
> Rails 3.0.7
>
> Can you help a newbie??
>
Time/date objects have methods like year, month, day etc. which return
the individual components
Fred
> --
> 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@googlegroups.com.
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home