On 23 March 2010 18:05, David Ishmael <lists@ruby-forum.com> wrote:
> I have a concrete table with an associated join table and I'm trying to
> load up some test data but cannot seem to get the fixtures file correct.
> The parent/child relationship works great but the fixtures fail to load.
> Any help would be greatly appreciated.
>
> Here is what I have...
>
> # app/models/node.rb
> class Node < ActiveRecord::Base
> belongs_to :category
> belongs_to :status
>
> has_one :parents,
Why is that not has_one :parent ?
> :class_name => "NodeGroup",
> :foreign_key => "child_id"
>
> has_one :parent, :through => :parents
That would only work if there were a relationship to a parents table
>
> has_many :children,
> :class_name => "NodeGroup",
> :foreign_key => "parent_id"
>
> end
>
> # app/models/node_group.rb
> class NodeGroup < ActiveRecord::Base
> belongs_to :parent, :class_name => "Node"
> belongs_to :child, :class_name => "Node"
> end
>
> # test/fixtures/nodes.yml
Should be node_groups.yml
> parent1:
> name: Parent1
> children: child1
I would have expected this to be
parent: Parent1
child: child1
Colin
>
> parent2:
> name: Parent2
>
> child1:
> name: Child1
> --
> Posted via http://www.ruby-forum.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 rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment