Working with date_select


#1

I am a little confused about the best way to work with date_select. I
see that
in my views it generates a simple input form that allows for the entry
of year,
month and date information. If I just leave it at that, great!

But what if now in the controller, I want to work with the date
information. I
actually want to take the user input date and compute a new date some
number of
days in the future.

How should I use “start_date(1i), start_date(2i), start_date(3i)” in a
controller to fill in a new SQL date column?

Does there exist helpers to convert from “start_date(1i),
start_date(2i),
start_date(3i)” to a Ruby Class like Date or Time?

Page 203 of “Agile Web D. with Rails” implies that SQL Types
like
“interval, date” are mapped to the Ruby Class “Date” and the SQL Types
“datetime, time” are mapped to the Ruby Class “Time”. Why isn’t it that
date_select returns a Date object?

Thanks in advance for setting my understanding straight in this matter.

–Dale


#2

Dale M. wrote:

Does there exist helpers to convert from “start_date(1i), start_date(2i),
start_date(3i)” to a Ruby Class like Date or Time?

Page 203 of “Agile Web D. with Rails” implies that SQL Types like
“interval, date” are mapped to the Ruby Class “Date” and the SQL Types
“datetime, time” are mapped to the Ruby Class “Time”. Why isn’t it that
date_select returns a Date object?

If start_date is an Active Record column of type Date it will be
automatically set from the three parameters when you call either
Model.new(params) or model_instance.update_attributes(params).

If however start_date is an attr_accessor in the model, you’ll have
to use the select_date helper instead.


We develop, watch us RoR, in numbers too big to ignore.