If I have two models:
class Post < ActiveRecord::Base
belongs_to :user
end
and
class User < ActiveRecord::Base
has_many :posts
end
If I do:
post = Post.new
user = User.new
post.user = user
post.save
Does the user get saved as well and the primary key properly assigned in post
's user_id
field?