Hi
I’m new to rails and ruby and am working through Agile Web D.
with Rails Edition 1 and have a question if someone could point me in
the right direction.
I have my table which has a datetime field
I generate a scaffold and in the new.rhtml page I get drop down lists
enabling me to choose a date.
If I wished to modify the range of available dates i.e. the years
where does scaffold look to choose this data ?
TIA Paul
The file you need to edit is _form.rhtml partial template and not the
new.rhtml, mainly the options of the datatime_select method
Check
http://api.rubyonrails.com/classes/ActionView/Helpers/DateHelper.html#M000469to
see what options you can use, for example :start_year => 1995 …
etc…
–
Thank you and kind regards
Rida Al Barazi
Paul J. wrote:
Hi
I’m new to rails and ruby and am working through Agile Web D.
with Rails Edition 1 and have a question if someone could point me in
the right direction.
I have my table which has a datetime field
I generate a scaffold and in the new.rhtml page I get drop down lists
enabling me to choose a date.
If I wished to modify the range of available dates i.e. the years
where does scaffold look to choose this data ?
TIA Paul
Hi,
I think Rails picks it from
\ruby\lib\ruby\gems\1.8\gems\rails-1.1.6\lib\rails_generator\generators\components\scaffold.
Alternatively, you may write your own code (and not use scoffold) to
get required range of dates (years etc) using datetime helpers.
As an example, add following code in your rhtml where you need the date
field:
date_select(“post”, “written_on”, :start_year => 1995,
:use_month_numbers => true,
:discard_day => true, :include_blank => true)
Check out details and other date time helpers at
http://railsmanual.com/module/ActionView::Helpers::DateHelper
HTH,
Ashutosh
On 21 Aug 2006 03:03:35 -0700, “Ashutosh” [email protected]
wrote:
TIA Paul
field:date_select(“post”, “written_on”, :start_year => 1995,
:use_month_numbers => true,
:discard_day => true, :include_blank => true)Check out details and other date time helpers at
http://railsmanual.com/module/ActionView::Helpers::DateHelperHTH,
Ashutosh
Hugh help,
Many Thanks Paul