[Opda-develop] OPDA/app/models subscription_list.rb,1.2,1.3
Brought to you by:
digitalpodcast
|
From: Alex N. <dig...@us...> - 2006-07-24 04:23:13
|
Update of /cvsroot/opda/OPDA/app/models In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5202/app/models Modified Files: subscription_list.rb Log Message: Changed model to acts as nested set set up subscription list views. Built browser tree for lists with channels in center div. see subscription_lists/list. Tree still needs some work. should be expanded to next level on entry and ajax toggle on minus sign needs to be fixed - currently set to display - but it is not toggling for some reason Index: subscription_list.rb =================================================================== RCS file: /cvsroot/opda/OPDA/app/models/subscription_list.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** subscription_list.rb 28 Jun 2006 22:02:42 -0000 1.2 --- subscription_list.rb 24 Jul 2006 04:23:11 -0000 1.3 *************** *** 2,5 **** belongs_to :user has_and_belongs_to_many :channels ! acts_as_tree :order => 'title' end --- 2,27 ---- belongs_to :user has_and_belongs_to_many :channels ! acts_as_nested_set :scope => :root ! ! def before_create ! # Update the child object with its parents attrs ! unless self[:parent_id].to_i.zero? ! self[:depth] = parent[:depth].to_i + 1 ! self[:root_id] = parent[:root_id].to_i ! end ! end ! ! def after_create ! # Update the parent root_id with its id ! if self[:parent_id].to_i.zero? ! self[:root_id] = self[:id] ! self.save ! else ! parent.add_child self ! end ! end ! ! def parent ! @parent ||= self.class.find(self[:parent_id]) ! end end |