Ruby on Rails Monday, November 28, 2011

On Mon, Nov 28, 2011 at 04:12, Colin Law <clanlaw@googlemail.com> wrote:

> On 27 November 2011 22:34, Dave Aronson
> <googlegroups2dave@davearonson.com> wrote:

>>  ruby-1.9.3-head :005 >   u1 = User.new
>>  => #<User id: nil, other details snipped>
>>  ruby-1.9.3-head :006 > u1.id = 1001
>>  => 1001
>>  ruby-1.9.3-head :007 > u2 = User.new
>>  => #<User id: nil, other details snipped>
>>  ruby-1.9.3-head :008 > u2.id = 1002
>>  => 1002
>
> It is not appropriate to set the id values manually.  Save them
> instead, then rails will allocate the ids.

Since it was just for the purpose of a little irb experiment, I didn't
want to go to the bother of setting up a new app or jumping through
the hoops to set the other fields needed to make the record saveable.

> Try again with letting rails manage the ids and you may get a different result.

Essentially my advice to the OP! :-) Let's see what he says.

-Dave

--
LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern languages.
Where: Northern Virginia, Washington DC (near Orange Line), and remote work.
See: davearonson.com (main) * codosaur.us (code) * dare2xl.com (excellence).
Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (Aronson)

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment