How I can use date from form via params?

Hi everybody !
Is somebody so polite and tell me, how I can use date from form via
params ?
For egzample:
I have form “customer”.
When I have to use in my controller customer name, I can write :
@name = params[:customer][:name]
But I haven’t idea how I can write date like “birthday”, which is in
form as
<%= date_select(:customer, :birthday) %>
When I wrote in controller:
@birthday = params[:customer][:birthday]
it doesn’t work.
Date is divide in params on tree parts like birthday(1i), birthday(2i)
birthday(3i) but I don’t know what is proper format to use it via
params.

Robert W. wrote:

Sorry, I don’t know if Rails supplies a convenient way to parse this
into a Date object individually. But, it likely has something for
that.

Thanks for your endeavor, Robert.

Because I wasn’t operated on ActiveRecord model, I used another helper
-> “select_date” with option “:prefix” in order to distinguish more than
one date. Then, it wasn’t so difficult parse date via params.

Best regards, Walde.

<%= date_select(:customer, :birthday) %>

As far as I understand it Rails is expecting :customer to be an
ActiveRecord subclass and :birthday to be an attribute of Customer.
When using params[:customer] in your controller for “mass assignment”
it will take care of setting my_customer.birthday automatically for
you.

Sorry, I don’t know if Rails supplies a convenient way to parse this
into a Date object individually. But, it likely has something for
that.

On May 15, 4:29 pm, Walde M. [email protected]

Hi,

I have exactly the same problem. I am using a form separated from any
model, and I use a date object. Then I send by mail the information
contained in this form.
However when I access to my date object in the template for the mail I
have a string looking like “(3i)2(1i)2007(2i)1(1i)
(3i)2(1i)2007(2i)1(2i)(3i)2(1i)2007(2i)1(3i)”.

I think the previous answer is what I am looking for but I can get it
to work, the method is not found…

Any help or suggestion to work over this?

Thanks
Chewbie

On 5/16/07, Walde M. [email protected] wrote:

Robert W. wrote:

Sorry, I don’t know if Rails supplies a convenient way to parse this
into a Date object individually. But, it likely has something for
that.

class Time
class << self
# Used for getting multifield attributes like those generated by a
# select_datetime into a new Time object. For example if you have
# following params={:meetup=>{:“time(1i)=>…”}} just do
# following:
#
# Time.parse_from_attributes(params[:meetup], :time)
def parse_from_attributes(attrs, field, method=:gm)
attrs = attrs.keys.sort.grep(/^#{field.to_s}(.+)$/).map { |k|
attrs[k] }
attrs.any? ? Time.send(method, *attrs) : nil
end
end
end


Rick O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com