Larry E. Lutz
2008-Apr-17  18:14 UTC
[Betternestedset-talk] move_to_child_of in after_save Callback
I''m trying to include a move_to_child_of in an after_save callback, but
no
matter how I do it, it seems to error out. Specifically, I''ve got a
attribute named bns_parent_id in my model (and associated field in the
table). I choose to create this field because I''ve been told that BNS
does
like it when you try to mess with it''s reserved fields (parent_id, lft,
and
rgt). I have a field for bns_parent_id in my view (but not for parent_id).
The I have the following in my model:
  def after_save(record)  
    record.move_to_child_of record.bns_parent_id  
  end
I''ve tried multiple permutations of this callback, but they all seem to
error out. Does anyone have any idea how to make this work? (By the way, it
would be great if this or a similar type of functionality was incorporated
into BetterNestedSet.)
Larry E. Lutz 
lutzle at swbell.net 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 8270 bytes
Desc: not available
Url :
http://rubyforge.org/pipermail/betternestedset-talk/attachments/20080417/0651c2e5/attachment.bin
Krishna Dole
2008-Apr-17  18:49 UTC
[Betternestedset-talk] move_to_child_of in after_save Callback
you may want to take a look at ez_set (one of the branches in the same svn repository). it does all the moving for you. k On Thu, Apr 17, 2008 at 11:14 AM, Larry E. Lutz <lutzle at swbell.net> wrote:> I''m trying to include a move_to_child_of in an after_save callback, but no > matter how I do it, it seems to error out. Specifically, I''ve got a > attribute named bns_parent_id in my model (and associated field in the > table). I choose to create this field because I''ve been told that BNS does > like it when you try to mess with it''s reserved fields (parent_id, lft, and > rgt). I have a field for bns_parent_id in my view (but not for parent_id). > The I have the following in my model: > > > def after_save(record) > record.move_to_child_of record.bns_parent_id > end > > I''ve tried multiple permutations of this callback, but they all seem to > error out. Does anyone have any idea how to make this work? (By the way, it > would be great if this or a similar type of functionality was incorporated > into BetterNestedSet.) > > Larry E. Lutz > lutzle at swbell.net > > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > >