Datebocks formatting

Hello, I’ve started using datebocks yesterday, it seems amazing to me,
but I have
some problems I can’t solve. When I show a model’s date I do:

<%= datebocks_field(‘backup’, ‘bkdate’) %>

But the field in the database is a datetime so datebocks show me a
date as

2001/01/24 00:00:00

and I don’t want to see the time, only the date. How do I tell
datebocks to use another format?

Morover I’ve seen a bug:

When you show a date field with datebocks:

<%= datebocks_field(‘backup’, ‘bkdate’) %>

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! :slight_smile: