On Mar 18, 2011, at 2:38 PM, Mark Sobkowicz wrote:

> I'm trying to add a little jQuery magic to my hobo app.   I watched Ryan 
> Bates' lovely screencast (#213) on calendars, and got to work.  I got it to 
> work, as long as there is already a date in the field.   Here is some form 
> code:
> 
>  <form merge param="default">
>       
>     <error-messages param/>
>       <p><b>Customer </b>
>       <b><input:customer/></b></p><br/>
>       <p><b>Start Date </b>
>       <b><input:start_date type="text" size="20" class="datepick" 
> value='&this.start_date.strftime("%m/%d/%Y")'/></b></p><br/>
>       <p><b>End Date <input:end_date type="text" size="20" class="datepick" 
> value='&this.end_date.strftime("%m/%d/%Y")'/></b></p><br/>
> 
> 
> 
> Typically, there is a start_date but no end_date.   When I use this form on 
> the "edit" page with the end date commented out, it works!  When the end date 
> input is left in, I get the message:
> 
> undefined method `strftime' for nil:NilClass
> 
> on the end_date input.
> 
> I put 
> 
> attr_accessor :end_date, :type => :date
> 
> in my Rental model, but it still doesn't work.

Correct, since the value's still nil. :)

In any case, this is a great spot to use _?:

this.end_date._?.strftime("%m/%d/%Y")

will only do the strftime if the value isn't nil.

--Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to