HI Colin,

On Tue, Dec 6, 2011 at 8:46 AM, Colin Law <[email protected]> wrote:
<snip>

>> ruby-1.9.2-p290 :006 > p.only_child.create(:name => 'sam')
>>  OnlyChild Load (0.4ms)  SELECT "only_children".* FROM
>> "only_children" WHERE "only_children"."poppa_id" = 1 LIMIT 1
>> NoMethodError: undefined method `create' for nil:NilClass
>
> I think you have to use create_association for a has_one rather than create. 
> See
> http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html
> p.only_child returns a record (or tries to) and so cannot have a
> create method that does what you want.

Yep.  That was it.  Thanks.  If I think about it real hard and hold my
mouth just right it makes a little bit of sense ;-)

Best regards,
Bill

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

Reply via email to