On 10/30/07, nigel.bris
<nigel.bris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> Hi,
>
> I am wondering why this does not work?
>
> Email.find(1).the_file.create
It doesn''t work because that''s now how you do it. has_one
works
differently from has_many.
>
> Email model
> has_one :the_file
>
> Email.find(1).the_file always returns nil (until there is an
> association) and you cannot do a create... Any suggestions?
Per the docs:
Email.find(1).create_the_file(attrs)
see:
http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#M000656
HTH
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---