similar to: has_many :through problem

Displaying 20 results from an estimated 20000 matches similar to: "has_many :through problem"

2006 Jul 04
1
Has_many :through with checkboxes?
Just when I started getting the hang of has_and_belongs_to_many relationships, I realize that I should probably convert several of my app''s joins to has_many :through type relationships. One example, pairing users with categories via subscriptions, where each user can be the "owner" of a category, has given me particular trouble when I try to update a user''s
2009 Jun 22
5
has_many through , or habtm , using form
i think there ara two ways of relate products and categories , basically i want to fix one product(e.g hp dv7....) to some categories (notebook,17"notebooks...) i made a table named categorization(incuding category_id,product_id fields) then in models i write these codes below class Product < ActiveRecord::Base has_many :categories, :through => :categorizations
2006 Nov 21
14
Starting from scratch
I have the following models: === class Person < ActiveRecord::Base has_many :person_organisations, :dependent => true has_many :organisations, :through => :person_organisations has_many :person_categories, :dependent => true has_many :categories, :through => :person_categories end class Category < ActiveRecord::Base has_many :person_categories, :dependent => true
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 Jan 18
2
categories/recipes & books/descriptions - has_many vs has_one => id question
People, In the cookbook eg, categories has_many recipes but in a book eg, book has_one description - doesn''t that mean that the id of the description should be the same as the id of the book (instead of having it''s own "description_id" in the book table? Thanks, Phil. -- Philip Rhoades Pricom Pty Limited (ACN 003 252 275 ABN 91 003 252 275) GPO Box 3411 Sydney
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.
2006 Apr 20
3
has_many :through with has_many/has_many join models
It seems that using a join model that joins with two has_many''s will fail to generate proper SQL class StudentSemesterRecord < ActiveRecord::Base belongs_to :semester has_many :discipline_records, :through => :semester end class Semester < ActiveRecord::Base has_many :student_semester_records has_many :discipline_records end class DisciplineRecord <
2006 Jul 23
4
has_many AND has_many :through ?
Hi, I am working on a scheduling app and I have a perpelextion (new word). I am wondering if the problem is my data model I have Users. Users can create Events. Users can be invited to Events created by other Users. So... user.rb class User < ActiveRecord::Base has_many :invitations # invitations to other users'' events has_many :events, :through => :invitations # all events
2010 Jan 27
2
has_many, through with nested models?
First the data model: class Forum < ActiveRecord::Base has_many :topics, :dependent => :destroy, :order => ''created_at desc'' end class User < ActiveRecord::Base has_many :topics, :dependent => :destroy has_many :comments, :dependent => :destroy has_many :replies, :dependent => :destroy end class Topic < ActiveRecord::Base belongs_to
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
2006 Aug 02
2
Self-Referential has_many :through
Hello all. I am trying to create a self-referential has_many :through. I used the following site as a guide http://blog.hasmanythrough.com/articles/2006/04/21/self-referential-through but it still doesn''t appear to be working. I have two models. Person and Relationship. A person has many contacts (Which is another person) through relationships class Person < ActiveRecord::Base
2010 May 25
2
Site Navigation With Polymorphic Has Many Through
Hi, seem to keep running into a wall here. I can''t find any resources on site navigation that can deal with any model being in the nav, allow nesting, and can dynamically update. So I thought about it for a while, and decided on a MenuItems class, which contained the position of the child in relation to it''s siblings, where the parent and the child were polymorphic. Then a given
2006 Jan 26
4
Override has_many :order at run-time?
Is it possible to override has_many''s :order attribute at run-time? e.g. something like: <% for category in @site.categories(:order=>''name'') %> ... <% for category in @site.categories(:order=>''rank'') %> ... thanks csn -- Posted via http://www.ruby-forum.com/.
2006 Feb 21
7
has_many :through failing to save changes
Hi all, I''m messing around with has_many, and has_many :through (on edge rails), using a join model. Branches and Projects join through ProjectsAtBranches. If I do @branch.projects, I can see the associated projects, and visa-versa, if I manually put them in the join table. But I cannot do @branch.projects << Branch.find(blah), or @branch.projects.clear, and then save the
2006 Jul 02
1
prevent duplicate inserts with has_many :through ??
Does anyone have an efficient/elegant way to prevent duplicate inserts when using a has_many :through relationship. So I have something like this: class User < ActiveRecord::Base has_many :favorite_teams has_many :teams, :through => :favorite_teams end class FavoriteTeams < ActiveRecord::Base belongs_to :user belongs_to :team end class Teams < ActiveRecord::Base has_many
2006 Jan 10
5
Select Tag and Associations
Hi there, I''ve been working on this for awhile and have finally decided to ask for a little guidance.I have a slight problem trying to save a selection. I have two models: A "Posting" has_many "Categories", and a "Category" belongs_to one "Posting". With that said, in the posting model I have "has_many :categories" and within the
2006 Aug 01
2
has_many :through a belongs_to relationship
I have users who belong to a group. I also have a room that belongs to a group. I want to use a has_many through association to link the room and the users as such: class Room < ActiveRecord::Base belongs_to :group has_many :users, :through => :group end The SQL generated for the search is incorrect: SELECT users.* FROM users INNER JOIN group ON users.group_id = groups.id WHERE
2006 May 11
6
ActiveRecord associations
Can someone clarify this for me? Suppose I have two tables like: class Company < ActiveRecord::Base belongs_to :category end class Category < ActiveRecord::Base has_many :companies end I understand that the belongs_to causes related companies to be read from the db when I ask for a category. I suspect SQL something like select * from categories, companies where category.id
2006 Mar 30
5
Has_many :through problems -- please help
I''m having a lot of trouble with has_many, :through and could really use some assistance. I''ve got a User and Group class. Users can subscribe to groups, and groups should know who''s subscribed. I''ve got a join table (group_subscriptions) with group_id, user_id, and it''s own id element. Users has "has_many :groups, :through =>
2006 Apr 04
1
Manipulating has_many :through associations
Hi, I haven''t done any associations before, so please forgive my incorrect use of terminology... If I set up a has_many :through association, can I manipulate the associated instances directly (like an Array), or do I need to manipulate the join model? For example, suppose I have two classes and the associated join model: class foo has_many :foo_bars has_many :bars, :through