Newbie help with scaffold generator

P

Paul Johnston

Hi
I'm new to rails and ruby and am working through Agile Web Development
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
 
A

Ashutosh

Paul said:
Hi
I'm new to rails and ruby and am working through Agile Web Development
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
 
P

Paul Johnston

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

Hugh help,
Many Thanks Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top