similar to: How to describe self join in a model

Displaying 20 results from an estimated 30000 matches similar to: "How to describe self join in a model"

2006 Jun 17
5
Having trouble listing tiers of categories
I have categories and sub-categories in a table called "categories". Every row has a "parent" field to note if the entry is the sub-category of another (never goes deeper than 1 level). So there might be something like this: id | name | parent 1 Dog 0 2 Pug 1 3 Siamese 5 4 Shih Tzu 1 5 Cat 0 6 Wiener Dog 1 7 Persian
2006 May 25
5
Model Structure Advise
Hi, I''m starting to build a simple (?!) FAQ system, and I''d like some advice on setting up the model relationships. I was going to go with a simple system of a Category table and a FAQ table (holding questions and answers) - where one FAQ belongs to one category. That''s all nice - a simple has_many / belongs_to relationship. Then I decided to add another level - Area.
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 Apr 15
8
Inheritance in Rails - I need some help
I''ve got a model, "category" and another model "subcategory." Each subcategory belongs_to a category, and a category has_many subcategories. What I need to do is set it up so that I can search Category and Subcategory with one .find call. So: Category.find(:all, <etc) will find categories and subcategories. Now, I believe this can be done by making
2005 Dec 24
1
best way to design uknown depth of subcategories
Hello, What would be the best way to design a table of posts that belong to a unknown depth of categories. Say i wanted to display the posts of data (i.e., craigslist) but the category could be something like NewYork/RealEstate/Housing/ForSale/ByOwner. Would acts_as_tree work best here and assign each sublevel to a different id? just trying to take the easiest approach here using the best
2005 Jul 25
2
acts_as_tree and traversing parent/child relationships
I am working on an Rails application that uses a pretty complex category structure through out the site. I have defined a table to house all the info and a FK to reference parents within the table CREATE TABLE categories ( id int(11) NOT NULL auto_increment, name varchar(50) NOT NULL, parent_id int(11) default NULL, constraint fk_category_id foreign key (category_id) references
2005 Sep 23
6
problem with acts_as_tree
Hi, I''m using the latest gem version of rails under MacOS Tiger. I was trying to use acts_as_tree as described in the rails book. So I have something like: class Category < ActiveRecord::Base acts_as_tree :order => "title" end create table categories ( id int not null auto_increment, title
2005 Oct 19
3
Finding all parents of acts_as_tree relationship
I''m using acts_as_tree to maintain a hierarchy of categories (each top-level category can contain multiple categories and each sub-category can contain multiple sub-categories, etc.). I want to be able to find all parents of a particular category. I realize that I can use @category.parent or even @category.parent.parent to move up in the hierarchy, but I need this to happen dynamically
2006 Jan 15
2
acts_as_tree & acts_as_list for a single model?
Hi, If I have a db table categories - id - name - parent_id - position is it alright to have the Category model act_as_tree and for each level act_as_list? class Category < ActiveRecord::Base acts_as_tree :order => :position acts_as_list :scope => :parent_id end Thanks, Peter
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/.
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 Mar 10
8
multiple sub categories (parent-child)
hi. base from the cookbook example, where each categories can have many recipes, id like the categories to have multiple sub categories, unlimited levels. please show some code, as i am new to Ruby and Ruby On Rails. thanks -- Posted via http://www.ruby-forum.com/.
2006 Apr 20
4
Many to Many Category structure with itself
Basically, I''m trying to have a table called "categories" have a many to many relationship with itself. But I also want each catagory to be able to be "copied" into another category so it is essentially a child category to more than one parent. To me the obvious way of doing this is by creating another table called category_maps (and a model called CategoryMap).
2005 Oct 26
1
acts_as_tree parent id problem
Hi all, I have a simple Category model which acts_as_tree. In the form partial, I use a select form helper to display all the categories so that the user can choose a parent category. This works fine, but when I submit the form, I get an AssociationTypeMismatch It seems that the parent id that I pass back into the controller is being treated as a String, rather than finding the appropriate
2008 Jul 31
1
Getting a a list of acts_as_tree items with hierarchy
I''m using acts_as_tree to nest categories n-levels deep and am wondering if anyone out there in Ruby-land knows the best, least expensive way to start with top level categories and then loop recursively through each category going as many levels deep as needed, and then moving to the next top level category, etc. Thanks, Josh -- Posted via http://www.ruby-forum.com/.
2006 May 12
2
Has many through join table issues
I''m trying to wrap my caffeine soaked brain around has_many :through following along at: http://rails.techno-weenie.net/tip/2005/12/23/teaching_your_blog_model_new_tricks_with_has_many_through I think my models are a little more complex than what fits this narrative. I have a directory of members, each member can belong to multiple categories. The category table references itself
2007 May 02
3
acts_as_tree related question
hi, I''ve a normal Category model implemented with acts_as_tree (name, parent_id) that has_many :products (name, category_id). What I''m asking for is a method to fetch every product that belongs fall into a particular category and its children, eg: if I''m asking for a root node (/category/show/1) I need to display every product that have category_id = 1 AND every product
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 Jul 22
4
single table inheritance problem
Hallo, I am having a very strange Problem with STI in my application. setup: - two tables one called "wikis" on called "categories" with a hbtm relationship. - the wikis table is the sti one with a model PageWiki being extended from Wiki (and the correspondig type column) Following happens: - server restart - get :wikis, :show_pages - in show_pages the first line says
2006 Apr 12
2
Why doesn''t acts_as_tree support :scope?
I want to implement a unique category tree per user in my system, and I was hoping to use "acts_as_tree" on my category model. It seems as if acts_as_tree makes the assumption that the entire table the model is off of is one large tree. I actually want each user to have their own category trees all stored in the category table so I need it to scope off of the user_id.