shagymoe wrote:
> The models actually look like this: (notice the "has_one :page")
> 
> class Project < ActiveRecord::Base
>   has_many :documents
> end
> 
> class Document < ActiveRecord::Base
>   has_one :page
>   belongs_to :project
> end
> 
> class Page < ActiveRecord::Base
>   belongs_to :document
> end
> 
> Interestingly, your suggestions successfully save the document with:
> 
> project.documents << document
> 
> But the following fails:
> 
> document.page << page
> 
> However, it is successful when I specify the document.id in the
> attributes manually.  Could there be a bug with has_one or am I just
> doing something wrong?

Unlike has_many, has_one isn't an AssociationCollection, and
doesn't use the << concat operator. Instead:

document.page = page

or

document.create_page(:attribute1 => value1, ...)

-- 
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to