similar to: acts_as_tree validation on parent.children.create

Displaying 20 results from an estimated 20000 matches similar to: "acts_as_tree validation on parent.children.create"

2007 Feb 14
3
eager loading parents and children (acts_as_tree)
I am struggling with how to do eager loading of an acts_as_tree model. If the model Stuff acts_as_tree I know I can do this to get children as well: Stuff.find(:all, :include => :children) But what if the model I am including is the one that acts_as_tree? For example, say Picture belongs_to Category. Category acts_as_tree and I want to get all pictures that are members of a category that
2006 Mar 25
2
acts_as_tree wierdness with children.count and children.size
i am making a category tree and i iterate over the category using my counter_cache however it would show a different number than what was actually being represetned in the tree. Here is an example cat.children = [cat2, cat3] puts cat.children.size 2 puts cat.children_count 2 cat4.parent_id = cat.id cat4.save puts cat.children.size
2005 May 09
0
acts_as_tree / moving children
Greetings! I am working on a model that utilizes "acts_as_tree". I have a table named ''categories'' that has multiple root items, each each root item has several children. I cannot successfully separate those children from the tree. For example, if I delete a root category, I want the sub categories to become roots. I have tried setting the
2012 Jun 08
7
filter children with acts_as_tree
Hello Experts, I have a tree of categories in this category object there is a property called type. the root categories have no type but the children have. so how I can get all the roots with filled in children that have category type = ''B'' for instance. I tried to run Category.roots then delete children With a category not equal to ''B'' but this causes a major
2006 Jun 03
2
Parent listing children.
My database is set up as Categories > Things associated by category_id and has_many and belongs_to. How would I go about listing all the categories and under each Category is it''s children? Is there an easy rails way to do this - preferably without using acts as tree? Any help is appreciated - thanks! -- Posted via http://www.ruby-forum.com/.
2006 Jul 20
3
acts_as_tree
Hello, I''m trying to create categories that have their own subcategories, and each subcategory may have its own subcategories, .. and so on. After some reading, I found out that the best way for creating such a thing is to use acts_as_tree, but I didn''t find any tutorial or article that explain this in a clear way. After a lot of work I was finally able to create categories and
2007 Mar 11
0
eager loading with acts_as_tree
Sigh, I have a new problem every day. Okay I have a model that acts_as_tree, so I am trying to eager load the objects + all of their children, plus their children''s children, and so on. However, :include => :children alone doesn''t do this, and so far I''ve got something like: :include => [{:children => [{:children => [:children, :upload]}, :upload]},
2010 Feb 09
3
acts_as_tree question
Hi, I''m trying to implement a very simple acts_as_tree search in my index html. I am able to show the parents, with no issue, but the children will not show. I have something like this for the parent, which displays fine: <% for group in Group.roots %> <td> <tr> <a href="#" onclick="Effect.BlindDown(''show_<%=
2006 Apr 15
0
parent.children not updated (has_many)
Hi guys! class Parent < ActiveRecord::Base has_many :children end class Child < ActiveRecord::Base belongs_to :parent end I do: parent = Parent.find(1, :include => :children) parent.children.find(3).update_attribute(''name'', ''Tom'') (or parent.children.find(3).name = ''Tom'') parent.children.find(3).name => ''old
2006 Jun 19
0
Eager loading and acts_as_tree
Hi all, I have a node structure which acts_as_tree. I am pulling the first two levels under the root node with: @root = Node.find(1, :include => [ { :children => [ :children, :parent ] }, :parent ]) How do I pull out the first three levels? What about four? @root = Node.find(1, :include => [ { :children => [ { :children => [:children, :parent] }, :parent ] }, :parent ])
2006 Nov 04
1
acts_as_tree repeats
Hello Railslist, I want to draw a simple single-table Acts_as_tree model. I''ve read some articles about it and read the API docs, and now I''ve got this running: in controller I have: --- def index @pages = Page.find(:all) end --- in the model for Page I have ofcourse: --- acts_as_tree :order => "position" --- in the helper I have; --- def
2006 Jan 19
0
Problem with an Tree-like object hierarchy (ActiveRecord acts_as_tree)
Hello people on rails, I am developing a web interface for a database that has hierarchical data. I want the user to be able to browse the tree (~1300 nodes) and activate/deactivate and showing/hiding groups of nodes (like selecting one node selects all the children and the leafs). So I have a tree of objects (ActiveRecord acts_as_tree). Because I need the tree to be persistent and I
2007 Nov 16
0
ZFS children stepping on parent
I was doing some disaster recovery testing with ZFS, where I did a mass backup of a family of ZFS filesystems using snapshots, destroyed them, and then did a mass restore from the backups. The ZFS filesystems I was testing with had only one parent in the ZFS namespace; and the backup and restore went well until it came time to mount the restored ZFS filesystems. Because I had destroyed
2006 Sep 13
1
Eager loading with acts_as_tree
So I have a model that acts_as_tree and I run a method on a collection of all of these records. This method walks the tree and fetches the parent/children, etc. This results in many, many duplicate SQL queries to be executed. Is there a way to eagerly load all of these models? Something along the lines of: Model.find(:all, :include => [:children, :parent]) If I execute the above statement, I
2006 Jun 13
4
When saving parent fails, children will still be updated
Hi all, When submitting a master/detail form I first want to handle the children before saving the parent. There are has_many and belongs_to relations between the parent and the children, so I can edit the children using (psuedo-)code like: child.destroy for deleting, child.update_attributes for updating and @parent.children.push(child) for adding child-records. I update the parent by using:
2006 Feb 23
3
has_many: inserting children when inserting parent
disclaimer: am in the midst of my first ruby/rails project I have a situation where I want several child records to be created when a new parent record is created. The following represents my first stab at coding it, am I on the right track? Here is the model: parents ---------- id name children ---------- id parent_id name class Parent < ActiveRecord::Base has_many: children end
2007 Jan 23
0
validates_presence_of fields. in parent ok, but how in children?
i have the problem that my child class fileds aren''t validated on saving the parent. working with parent and child works without problems. if all fields are filled correctly everything is saved as expected. but missing fields in the child arent added to the errors. following short sample shows what i try: Model ----------------------------------------------------- class Parent <
2006 Mar 23
1
using :include with acts_as_tree?
Is there a way to eager load children with a model that acts_as_tree? I tried: :include => :children but it gives a mysql error... Thanks, Justin
2006 Jul 17
1
acts_as_tree and :include
hello there, i have a model that uses acts_as_tree: >class GbEntry < ActiveRecord::Base > acts_as_tree :order => ''created_at DESC'' >end and i want it to paginate, including all children to avoid unnecessary db queries: > @gb_entry_pages, @gb_entries = > paginate :gb_entries, :per_page => 15, :order => ''created_at DESC'',
2005 May 17
8
acts_as_tree elegant tree printing
Hi, I''m working with acts_as_tree to print an unordered list of items: Root -- Child ---- Child I''ve got this working, however I''d like to know if there is a more elegant fashion that I''m unaware of: #Takes a parent category and recursivley returns all children def find_all_subcategories(category) if category.children.size > 0