[Rails] ActiveRecord: manually setting :id
Steve Sloan
steve at finagle.org
Sat Dec 17 04:07:53 GMT 2005
Andrew O'Brien wrote:
> I'm having a problem with ActiveRecord (outside of Rails) where it
> doesn't allow me to set the value of the :id column. Since you're
> probably not normally supposed to fiddle with the primary key, I'm
> guessing that this isn't a bug, but is intentional. Is there any way
> to override it?
Yes, if you mean that "Model.new(:id => 'foo').save" doesn't work. Try
"Model.new { |m| m.id = 42 }", that seems to work for me.
-- Steve
More information about the Rails
mailing list