similar to: Model extends and belongs_to another model - problem

Displaying 20 results from an estimated 10000 matches similar to: "Model extends and belongs_to another model - problem"

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
2006 Mar 30
5
Heeelp - no idea what''s going wrong.
I''m working on a simple CMS. The main data type are "listings" a listing habtm (has_and_belongs_to_many) categories and subcategories. Subcategories belong_to categories. Subcategories are basically the same as categories, but they are treated differently in a few situations. The problem is, I can''t seem to write the view/controller/model code that allows me to
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
2006 Apr 07
13
Pop up menus - any ideas?
I''ve got a menu in which I have all of my categories as links. Each category also has subcategories. I want to set it up so when you mouse over the category the subcategories will pop up (to the right of the main list, but that''s just CSS). This is what I have so far: <% for category in @categories %> <a href="#"
2006 Mar 31
7
Checkboxes expand to show new options when checked?
I''m writing a simple CMS where every item ("listing") HABTM categories and subcategories (which themselves belong_to a category). What I''m trying to do now is create a UI effect for listing creation: when you go to create a listing, only the possible categories will be shown, but when you select a category a set of new categories will be displayed like so: Lions
2006 Apr 11
2
Finding items from two models - then merging them
I have a model, listings. Listings habtm categories and subcategories, which are seperate models. What I want to do is search categories for certain items, like so: @categories = Category.find(:all, :conditions => ["name LIKE ?", "#%{:search_string}%" and subcategories for the same: @subcategories = Subcategory.find(:all, :conditions => ["name LIKE ?",
2006 May 23
7
has_and_belongs_to_many question
Hello, I am trying to make the "switchover" to programming my apps in Rails and have a question about database structure. In the past i would structure a many to many like this: categories ---------------------------------------------------- | id | name | ---------------------------------------------------- 1 Some Category 2 Another
2009 Oct 15
10
AJAX - how to have multiple select form sets implemented?
hi, there :) Consider a blogging application whereby a user is trying to add a new blog. He/she has to select a category. Upon selecting a category from a drop down box, a new sub categories drop down box will be created (hence an AJAX call). Got this implemented and it''s ok. Now, let''s assume that a given blog can have multiple categories (and subcategories). For example, a
2006 Apr 09
1
select helper question
Hi there, I try to develop a medical application using ruby on rails. There are many categories which can contain subcategories. I defined the model like this: class Category < ActiveRecord::Base has_and_belongs_to_many :notes belongs_to :parent_category, :class_name=>"Category", :foreign_key=>"category_id" has_many :sub_categories,
2006 Mar 29
0
Many-to-many relationship with multiple models?
I have a simple CMS I''m creating, and the primary model is the "listing". A listing habtm (has_and_belongs_to_many) categories (up to two) - allowing the listing to print its categories and a category to print its listings. I also need subcategories, which are different from categories in two ways: a listing can have as many subcategories (from it''s two categories)
2009 Feb 21
3
belongs_to or has_many
2 tables Items and Categories Categories (id, name) Items (id, name, category_id) Category_id can be null, and there are Categories that has not an Item. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email
2005 Dec 20
3
Single controller to browse things in categories
First off, hi, I''m [obviously] new :O) Please excuse my question as I''m sure it''s been answered, but I can''t find it anywhere. I have a table of categories: id name 1 Foo 2 Bar I have things which belong_to categories: id category_id subject date 1 1 my subject 07/09/2004 and Further classifications which belong_to categories: id category_id name 1 1 More
2009 Apr 05
5
Use a value from a different model
Hello, I cannot find the issue and it drives me crazy :( let''s simplify. I have 2 models: saving and purchase_type a *saving* corresponds to a *purchase_type* e.g. new sourcing or renegotiation a saving has exactly one purchase_type and a purchase_type has many savings. when I try to display the list of savings and their purchase type (name, not Id), i get the dreaded "You have a
2006 May 07
2
Category and subcategories in database
I have a project I''m trying to decide if I want to use rails for. I''m new to rails, so I''m not sure how easy it would be to implement something like this using ActiveRecord. Here''s the situation: Category > subcategory > subcategory > product Category > subcategory > product Some categories will have many subcategories, others few. I want
2006 Jun 29
4
Multiple belongs_to
Let''s say I have a catalog with hotels. Each hotel belongs to a category (4-star, 5-star etc.) This is it''s official category.However, there is also a category that users assign and a category that "independent reviewers" assign. So I have this: hotels { id, category_id, reviewer_category, user_category } categories { id, name } class Hotel <
2008 Dec 25
5
One question about Dynamic Select Menus
Hi all, Merry X''mas first :-) I have "Product","Category","Subcategory" 3 Model, and when new "Product", I want to use "Dynamic Select Menus" just like Ryan mentioned in http://railscasts.com/episodes/88-dynamic-select-menus I have everything down. But when I visit the js file, I got following error Showing
2007 Oct 05
1
Custom helpers for list of options?
Hi all, I have a model that "belongs_to" many other models, many of those models are just list of names, like country, state, city, profession ... I read about the country_select helper. Is better to have all those tables or use custom helpers? what the rails way? Thanks. For example : http://pastie.caboo.se/104092 # = Schema # country_id integer # city_id integer #
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
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 23
3
Newbie: Display hierarchical Records in a view
Hi, I have two models: category and subcategory. (one to many relationship), and a controller ''home'' I''d like to display all the categories and their sub categories in the view: home\index.rhtml. I have a method in the ''home'' controller'' like this: def list_categories @categories = Category.find(:all) end This list all the categories