Is there any way of overriding a model\'s id value on create? Something like:
Post.create(:id => 10, :title => \'Test\')
would be ide
This case is a similar issue that was necessary overwrite the id with a kind of custom date :
# in app/models/calendar_block_group.rb
class CalendarBlockGroup < ActiveRecord::Base
...
before_validation :parse_id
def parse_id
self.id = self.date.strftime('%d%m%Y')
end
...
end
And then :
CalendarBlockGroup.create!(:date => Date.today)
# => #
Callbacks works fine.
Good Luck!.