Seth Rasmussen
2005-Sep-19 23:59 UTC
Scaffolding: date field generating year select with value 2000+ only
The subject line pretty much says it all. I have just started a new app and done nothing more than create my controller and model, and put in the scaffold method call passing it the appropriate model. The new action displays the form as expected but for one thing: the ''year'' select of the three generated for my date field only provides values 2000 and up. How do I change this? Is there a special naming convention I should use because it is a date of birth field?
Ray Baxter
2005-Sep-20 00:25 UTC
Re: Scaffolding: date field generating year select with value 2000+ only
on 9/19/2005 4:59 PM Seth Rasmussen said the following:>The subject line pretty much says it all. I have just started a new >app and done nothing more than create my controller and model, and put >in the scaffold method call passing it the appropriate model. The new >action displays the form as expected but for one thing: the ''year'' >select of the three generated for my date field only provides values >2000 and up. How do I change this? Is there a special naming >convention I should use because it is a date of birth field? > >Somewhere in your views, probably in _form.rhtml, there is a date_select. Add, or change the :start_year parameter. Something like, date_select( :start_year => 1900 ) would do the trick. Ray
Seth Rasmussen
2005-Sep-20 01:06 UTC
Re: Scaffolding: date field generating year select with value 2000+ only
Ray, you''re sort of like my guardian angel here so far. ;)> Somewhere in your views, probably in _form.rhtml, there is a date_select. Add, or change the :start_year parameter. > > Something like, date_select( :start_year => 1900 ) would do the trick.Is _form.rhtml a template generated with the rails command that is referenced for the output of the scaffold method? Thanks.
Seth Rasmussen
2005-Sep-20 01:15 UTC
Re: Scaffolding: date field generating year select with value 2000+ only
Ah, I see the file you were speaking of is created when the scaffold method is called from the generator script. I was wondering if there is anyway to edit that select as I had discussed while using the dynamic scaffolding created by using the scaffold method in the controller.
Ezra Zygmuntowicz
2005-Sep-20 01:19 UTC
Re: Scaffolding: date field generating year select with value 2000+ only
On Sep 19, 2005, at 6:06 PM, Seth Rasmussen wrote:> Ray, you''re sort of like my guardian angel here so far. ;) > > >> Somewhere in your views, probably in _form.rhtml, there is a >> date_select. Add, or change the :start_year parameter. >> >> Something like, date_select( :start_year => 1900 ) would do the >> trick. >> > > Is _form.rhtml a template generated with the rails command that is > referenced for the output of the scaffold method? > > Thanks. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >Seth- There''s a difference between using the scaffold command in your controller like scaffold :model and generating a scaffold on the command line. I think what you want is to explicitely generate the code on the command line like this: #from the root of your rails project assuming you want a PostController and a Post model $ ruby script/generate scaffold post Post If you do it this way rails will generate all the code for your scaffold and let you edit it however you want. When you just run the scaffold command in your controller rails generates the scaffold code behind the scenes and you won''t ever actually _see_ the code. So try runnnig the generate scaffold command and then look in you app/ controllers app/models and app/views forlders and you will get to see the code and build on it. This is a great way to see what''s actually going on and the you can customize your app from a running start. HTH -Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732