search for: move_to_child_of

Displaying 11 results from an estimated 11 matches for "move_to_child_of".

2007 Jul 18
10
Rails - Mock going out of scope?
...root" do # Passes @language.should_receive(:name).exactly(:once).and_return("Japanese") @node.language_name.should == "Japanese" end it "should return it''s parent''s language if it is a child" do # Fails (message below) @section1.move_to_child_of(@node) @chapter1.move_to_child_of(@section1) @language.should_receive(:name).exactly(:once).and_return("Japanese") @section1.language_name.should == "Japanese" @language.should_receive(:name).exactly(:once).and_return("Japanese") @chapter1.language_...
2009 Feb 20
1
better nested set and parent_id
Hello everybody I have a model with better_nested_set. In my "new" form, i pass the desired parent_id as a hidden field, and in the create action at the controller i save the new register and use move_to_child_of Model (params[item][parent_id]) Everything works, but at my log file it warns that i can''t mass asign the property "parent_id". What can i do to avoid the warning? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the...
2011 Mar 08
2
Rails - Acts as Nested - Impossible move, target node cannot be inside moved tree.
...I''m using the Awesome Nested Set plugin: https://github.com/collectiveidea/awesome_nested_set And in my model I do the following: acts_as_nested_set after_save :ensure_max_nestedset_level private def ensure_max_nestedset_level if self.level > 2 self.move_to_child_of(parent.parent) end end I do this to keep the levels from getting to deep. Any idea why I''m getting this "Impossible move, target node cannot be inside moved tree." error? What''s strange is it happens on production but I can''t replicate it on Dev....
2009 May 22
1
[PATCH server] fix for BZ #477796: pool name uniqueness
...3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/app/models/pool.rb b/src/app/models/pool.rb index 2979fcb..0a63723 100644 --- a/src/app/models/pool.rb +++ b/src/app/models/pool.rb @@ -65,6 +65,9 @@ class Pool < ActiveRecord::Base transaction do save! move_to_child_of(parent) + # second save! call is to trigger validation rules related to parent_id + # since this nested set API call bypasses the standard AR validation + save! parent.permissions.each do |permission| new_permission = Permission.new({:pool_id => id,...
2009 Feb 20
0
Nested set - problems when creating child item
Hi, I''ve created a Model with Better Nested Set, but i''m having problems to create child items My workflow is: - In the (new) form, i pass the desired parent_id in a hidden field. - In the create action, i create the register and after saving it i use the move_to_child_of method. Everything works! My only problem is that Rails warns that I can''t mass asign the property "parent_id" How can i avoid this warning? Below is my create action: def create @invite = Invite.new(params[:invite]) begin @parent_invitee = Invite.find_by_id(par...
2009 Aug 19
10
acts_as_list / acts_as_tree / acts_as_nested_set - which one
I am creating forum application which needs usage of acts_as_list or acts_as_tree or acts_as_nested_set. I am unable to decide among these. please could some one recommend from their experience? -- Posted via http://www.ruby-forum.com/.
2007 Mar 17
0
Unit test problem -- BetterNestedSet?
...ser model that acts_as_nested_set using BetterNestedSet, my unit tests started failing. On investigation, I found that valid? wasn''t true for the records in question after they were created. Running the exact same sequence of tests by hand in the console -- creating records, then calling move_to_child_of on them -- works fine. If I comment out the validation, the tests run fine. Does anybody know what''s happening here? Thanks! --Al Evans -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed...
2010 Mar 08
0
betternestedset in rails 3.0
Hi Guys, when i upgraded my rails 2.3.4 to 3.0 my betternestedset is not working. It was working fine in the older version. This is my controller def new cat = Category.new cat.text=''test'' cat.save cat.move_to_child_of(Category.find_by_id(1)) #26 redirect_to :action => ''index'' end It gives me this error : "You cannot move a node if left or right is nil" app/controllers/categories_controller.rb:26:in `new'' Database looks like this : "id" "parent_id&q...
2011 Nov 23
0
Awesome nested set - how to put there items?
...have in a hidden input always the parent of item, that I just create. In a controller I do this: def create @user = User.new(params[:user]) respond_to do |format| if @user.save save_tree = TreeStruct.create!(:user_id => @user.id) save_tree.move_to_child_of(params[:parent]) format.html { redirect_to(root_url, :notice => ''OK.'') } format.xml { render :xml => @user, :status => :created, :location => @user } else format.html { render :action => "new" } f...
2006 Aug 06
2
better_nested_set plugin
Hi, I''m pleased to announce that the better_nested_set plugin is released. It ehances acts_as_nested_set, adding methods to move parts of the tree, like: * move_to_child_of * move_to_right_of * move_to_left_of Pass them an id or an object. Other methods added by this mixin are: * root - root item of the tree (the one that has a nil parent; should have left_column = 1 too) * roots - root items, in case of multiple roots (the ones that have a nil...
2010 Jan 25
9
skinny Controllers, fat models with REST?
...mp; (@addsubtask == true) ) ) respond_to do |format| if(@task.priority == nil) @task.priority = Priority.find(2) end @task.accepts_role ''Owner'', current_user if @task.save #Task an if @addsubtask @task.move_to_child_of(@task.parent_id) end @task.recalculate_progress_recursive flash[:notice] = ''Task was successfully created.'' format.html { redirect_to(@task) } format.xml { render :xml => @task, :status => :created, :location => @task }...