Because I didn't declare :parent_id property(is :tree genereates it
implicitily), so

http://github.com/drove/dm-more/blob/master/dm-is-tree/lib/dm-is-tree/is/tree.rb

Line 95:
options = { tree_options[:child_key] => nil }

should be changed to:

options = { :parent => nil }


On Jan 21, 11:48 am, sliu <[email protected]> wrote:
> My previous post can resolve the "NOT NULL restriction issue" using an
> explict :required => false option, but bring another issue.
> Since :required option is only accepted by belongs_to, not has n.
> So the two line I mentioned above should be modified 
> as:http://github.com/drove/dm-more/blob/master/dm-is-tree/lib/dm-is-tree...
> (L74-L75)
>
>         assc_options = { :model => options[:model], :child_key => Array
> (options[:child_key])}
>         has_n_options = options[:order] ? { :order => Array(options
> [:order]) }.merge(assc_options) : assc_options.dup
>         assc_options.update(:required => false)
>
>         belongs_to :parent, assc_options
>         has n, :children, has_n_options
>
> note:  assign assc_options.dup to has_n_options, and update :required
> => false option in the last line.
>
> On Jan 15, 5:25 am, sliu <[email protected]> wrote:
>
> > Save a root in dm-is-tree yield an validation error:
>
> > @errors={:parent_id=>["Parent must not be blank"]}
>
> > that's because root(s) node parent_id is NULL, but dm-is-tree calls
> > "belongs_to :parent" doesn't carry :required => false option.
>
> >http://github.com/drove/dm-more/blob/master/dm-is-tree/lib/dm-is-tree...
>
> > assc_options = { :model => options[:model], :child_key => Array(options
> > [:child_key]) }
> >  should be:
> > assc_options = { :model => options[:model], :child_key => Array(options
> > [:child_key]) , :required => false}
-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" 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/datamapper?hl=en.


Reply via email to