Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
ACts_as_nested_set with active scaffold
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
White Wizzard  
View profile  
 More options Nov 7 2007, 2:26 pm
From: White Wizzard <The.White.Wizz...@gmail.com>
Date: Wed, 07 Nov 2007 19:26:31 -0000
Local: Wed, Nov 7 2007 2:26 pm
Subject: ACts_as_nested_set with active scaffold
Hi all

I have a class that uses acts_as_nested_set.

class GreenRoom < ActiveRecord::Base
     acts_as_nested_set
     has_many :children, :foreign_key => :parent_id, :class_name =>
'GreenRoom'
     belongs_to :parent, :foreign_key => :parent_id, :class_name =>
'GreenRoom'
     "other fields"
end

The controller has

class GreenRoomController < ApplicationController
  active_scaffold :green_room do |config|
    "other configs"
    config.columns[:parent].ui_type = :select
    config.nested.add_link("Next Level", [:children])
  end
def conditions_for_collection
    return ['parent_id is NULL'] if !params.has_key?(:nested)
  end
end

this works in as expected in development but does not work in
production.  In production, when I click the nested link I get a
nested list that has one record and that record is the record I have
just clicked.

The message in production log is as follows

Processing GreenRoomController#nested (for 127.0.0.1 at 2007-11-07
13:21:17) [GET]
  Session ID: fce68e1a1b978fa6fdc15753b5f3e0c0
  Parameters: {"associations"=>"children", "action"=>"nested",
"_method"=>"get", "adapter"=>"_list_inline_adapter", "id"=>"3",
"controller"=>"green_room"}
Start rendering component
({:controller=>"green_room", :params=>{:parent_model=>GreenRoom, :nested=>true, :eid=>"850dabbfba55f39ff85bba073a6f2fef", :parent_column=>"children"}, :action=>"table"}):

Processing GreenRoomController#table (for 127.0.0.1 at 2007-11-07
13:21:17) [GET]
  Session ID: fce68e1a1b978fa6fdc15753b5f3e0c0
  Parameters: {"eid"=>"850dabbfba55f39ff85bba073a6f2fef",
"parent_column"=>"children", "nested"=>true, "action"=>"table",
"id"=>nil, "controller"=>"green_room", "parent_model"=>GreenRoom}
Rendering ../../vendor/plugins/active_scaffold/frontends/default/views/
list
Completed in 0.18920 (5 reqs/sec) | Rendering: 0.06854 (36%) | DB:
0.00786 (4%) | 200 OK [http://onetruth/green_room/nested/3?
_method=get&associations=children&adapter=_list_inline_adapter]

End of component rendering
Rendering ../../vendor/plugins/active_scaffold/frontends/default/views/
_list_inline_adapter
Completed in 0.28523 (3 reqs/sec) | Rendering: 0.01492 (5%) | DB:
0.00000 (0%) | 200 OK [http://onetruth/green_room/nested/3?
_method=get&associations=children&adapter=_list_inline_adapter]

Any help is appriciated

White Wizzard


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
White Wizzard  
View profile  
 More options Nov 7 2007, 3:22 pm
From: White Wizzard <The.White.Wizz...@gmail.com>
Date: Wed, 07 Nov 2007 20:22:52 -0000
Local: Wed, Nov 7 2007 3:22 pm
Subject: Re: ACts_as_nested_set with active scaffold
Found exactly where my problem is, and I don't know if there is a fix
for it . . .

"long Query "  childrens_green_rooms.parent_id = green_rooms.id WHERE
(green_rooms.id = '3') AND green_rooms.id IN ('3')   This is in
production, and in the development it is

"long query"      parents_green_rooms.id = green_rooms.parent_id WHERE
(green_rooms.parent_id = '4') LIMIT 0, 15 [0m
I dont know why there is this difference, and how to fix the issue of
different  queries being issued.    BTW is this active scaffold
creating the query or Rails?

White Wizzard


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
White Wizzard  
View profile  
 More options Nov 8 2007, 8:20 am
From: White Wizzard <The.White.Wizz...@gmail.com>
Date: Thu, 08 Nov 2007 13:20:00 -0000
Subject: Re: ACts_as_nested_set with active scaffold
Found a solution to this problem, for whatever reason it seems that
active scaffold could determine the reverse association fine on the
development machine and on the production it could not.   By putting
in   config.columns[:children].association.reverse = :parent in my
active scaffold config in the controller I wa sable to get the
relationship working.

White Wizzard


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MrBanabas@googlemail.com  
View profile  
 More options Nov 12 2007, 11:11 am
From: "MrBana...@googlemail.com" <MrBana...@googlemail.com>
Date: Mon, 12 Nov 2007 08:11:41 -0800
Local: Mon, Nov 12 2007 11:11 am
Subject: Re: ACts_as_nested_set with active scaffold
Hi Wizzard,

Do you use acts_as_nested_set plugin or BetterNestedSet?
I ve tried it with BetterNestedSet and the UI seems to work perfect,
but unfortunetly 'lft' and 'rgt' attributes are not set correctly.

Could you please take a look if they are set correctly in your app?

Thanks a lot in advance.

root node has lft = 1 and rgt = 2, which is obviously incorrect. right
has to be 2 * node_num for the root node.
At least as far I know.

--
volker

On Nov 8, 2:20 pm, White Wizzard <The.White.Wizz...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
White Wizzard  
View profile  
 More options Nov 12 2007, 2:12 pm
From: White Wizzard <The.White.Wizz...@gmail.com>
Date: Mon, 12 Nov 2007 19:12:59 -0000
Local: Mon, Nov 12 2007 2:12 pm
Subject: Re: ACts_as_nested_set with active scaffold
Hi Mr.Banabas

I used what was built into rails, in my green room model I have
acts_as_nested set.  I was not using better nested plugin.
Also I did not use lft and rgt in my database, I omitted them  ( due
to ignorance).  Anyways it worked for me in production.

White Wizzard

On Nov 12, 11:11 am, "MrBana...@googlemail.com"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MrBanabas@googlemail.com  
View profile  
 More options Nov 13 2007, 4:19 am
From: "MrBana...@googlemail.com" <MrBana...@googlemail.com>
Date: Tue, 13 Nov 2007 01:19:06 -0800
Local: Tues, Nov 13 2007 4:19 am
Subject: Re: ACts_as_nested_set with active scaffold
Hi Wizzard,

ok, I m using the better_nested_set...
and I just had to add the following to my controller:

def after_create_save(record)
   record.move_to_child_of record.parent.id unless record.parent.nil?
end

This line will set/update all lft and rgt attribute values.

Just for info...

--
Volker


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »