I''ve got a simple form that uses date_select and I''d love to have it automatically choose the next open date (bonus points: have it skip weekends). How would I do this? Thanks so much! Dan
http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001983 see the options list, :default Gavin http://handyrailstips.com On Jun 25, 8:26 pm, dansinker <dansin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve got a simple form that uses date_select and I''d love to have it > automatically choose the next open date (bonus points: have it skip > weekends). How would I do this? > > Thanks so much! > > Dan
Hmmm. So I did this: <%= date_select (''story'', ''rundate'', :default => nil) %></p> and it didn''t do anything--the date select still shows today''s date. Of course, the "nil" was a wild guess, so I tried the 3.days.from_now that''s in the example and it also showed today''s date. So, what am I doing wrong? Thanks!!! On Jun 25, 2:50 pm, Gavin <ga...-YMj/zd8x6QpKMzDMP321V2ksYUyLi9NM@public.gmane.org> wrote:> http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html... > > see the options list, :default > > Gavin > > http://handyrailstips.com > > On Jun 25, 8:26 pm, dansinker <dansin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I''ve got a simple form that uses date_select and I''d love to have it > > automatically choose the next open date (bonus points: have it skip > > weekends). How would I do this? > > > Thanks so much! > > > Dan
Still hoping for some help with this: I want date_select to automatically default to the next available calendar date--my app schedules things in advance, so that date may be a ways away. I can''t seem to figure out how to do this. Bonus complication: How would I get it to skip weekends in this process On Jun 26, 12:46 pm, sinker <dansin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hmmm. So I did this: > > <%= date_select (''story'', ''rundate'', :default => nil) %></p> > > and it didn''t do anything--the date select still shows today''s date. > > Of course, the "nil" was a wild guess, so I tried the 3.days.from_now > that''s in the example and it also showed today''s date. > > So, what am I doing wrong? > > Thanks!!! > > On Jun 25, 2:50 pm, Gavin <ga...-YMj/zd8x6QpKMzDMP321V2ksYUyLi9NM@public.gmane.org> wrote: > > > > >http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html... > > > see the options list, :default > > > Gavin > > >http://handyrailstips.com > > > On Jun 25, 8:26 pm, dansinker <dansin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I''ve got a simple form that uses date_select and I''d love to have it > > > automatically choose the next open date (bonus points: have it skip > > > weekends). How would I do this? > > > > Thanks so much! > > > > Dan
On Fri, Jun 26, 2009 at 1:46 PM, sinker<dansinker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hmmm. So I did this: > > <%= date_select (''story'', ''rundate'', :default => nil) %></p> > > and it didn''t do anything--the date select still shows today''s date. > > Of course, the "nil" was a wild guess, so I tried the 3.days.from_now > that''s in the example and it also showed today''s date. > > So, what am I doing wrong?Does @story.rundate already have a value? I''m pretty sure that the :default option only applies if the attribute is not already set. If you are editing an existing story then I''d think you''d want to initialize the select to the current value. If you''re creating a new story, then I think you want to initialize a new Story to have the rundate attribute set to the next open date before rendering the view. Now how you calculate that next open date is a matter of your own domain logic. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale