On 30 November 2010 10:14, Yan Bernatsky <li...@ruby-forum.com> wrote:
> I have 3 models
> Skill, User, UserSkill
>
> User has_many skills :through => :user_skills
> User has_many :user_skills
>
> UserSkill.new # => { :id => nil, :user_id => nil, :skill_id => nil }
> us = UserSkill.create(:user_id => 1, :skill_id => 1) # => { :id => nil,
> :user_id => 1, :skill_id => 1 }
>
> Why id is nil?
> In the database record was created and id is not null...

The id is not allocated until the record is saved to the database.

Colin

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to