it shows you the date in format: 2002/11/08 00:00:00. But that’s what I
said in my first post.
The bug heppens when you delete the triling time and lost the focus,
then it change the date to yyyy-mm-dd but it changes the value to
2008-02-11!!!
Well, I’ve solved this situation. My model has an attribute named
bkdate, yes, I know it’s a bit
strange but it’s a legacy system I’m making with Rails. Then I have
added two methods in
the model:
To show the date in the right format
def date
return bkdate.strftime("%Y-%m-%d")
end
This method does nothing but the framework asks for it.
def date=(value)
bkdate = value
end
In the view I’ve used date instead of bkdate:
<%= datebocks_field('backup', 'date') %>
And finally in the controller’s update method I added this line:
params[:backup][:bkdate] = params[:backup][:date]
to assign the date’s value to bkdate in params hash
And that’s all, it works!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.