# Newbie help with scaffold generator

**URL:** <https://www.ruby-forum.com/t/newbie-help-with-scaffold-generator/65777>\
**Category:** Ruby\
**Created:** [August 21, 2006, 11:30am UTC](https://www.ruby-forum.com/t/newbie-help-with-scaffold-generator/65777 "2006-08-21T11:30:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dohmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/439d5e/32.png) [@dohmer](https://www.ruby-forum.com/u/dohmer)\
**Post date:** [August 21, 2006, 11:30am UTC](https://www.ruby-forum.com/t/newbie-help-with-scaffold-generator/65777/1 "2006-08-21T11:30:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dohmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/439d5e/32.png) [@dohmer](https://www.ruby-forum.com/u/dohmer)\
**Post date:** [August 21, 2006, 11:44am UTC](https://www.ruby-forum.com/t/newbie-help-with-scaffold-generator/65777/2 "2006-08-21T11:44:47Z")

</div>

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](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

> **[Rida Al Barazi on about.me](https://about.me/rida)**
>
> I am an Entrepeneur in Toronto, Ontario, Canada. Visit my company website.

---

<div class="post-metadata">

**Author:** ![dohmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/439d5e/32.png) [@dohmer](https://www.ruby-forum.com/u/dohmer)\
**Post date:** [August 21, 2006, 12:06pm UTC](https://www.ruby-forum.com/t/newbie-help-with-scaffold-generator/65777/3 "2006-08-21T12:06:48Z")

</div>

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](http://railsmanual.com/module/ActionView::Helpers::DateHelper)

HTH,  
Ashutosh

---

<div class="post-metadata">

**Author:** ![dohmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/439d5e/32.png) [@dohmer](https://www.ruby-forum.com/u/dohmer)\
**Post date:** [August 21, 2006, 12:57pm UTC](https://www.ruby-forum.com/t/newbie-help-with-scaffold-generator/65777/4 "2006-08-21T12:57:05Z")

</div>

On 21 Aug 2006 03:03:35 -0700, “Ashutosh” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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::DateHelper](http://railsmanual.com/module/ActionView::Helpers::DateHelper)
> 
> HTH,  
> Ashutosh

Hugh help,  
Many Thanks Paul
