similar to: multiple has_many :through

Displaying 20 results from an estimated 30000 matches similar to: "multiple has_many :through"

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
2008 Aug 31
9
assigning collection values and exceptions
hi everyone, I''ve this code in my Report model: has_many :report_reasons, :validate => true has_many :reasons, :through => :report_reasons #, :uniq => true # :accessible => true def reason_attributes=(reason_attributes) reasons.clear reason_attributes.uniq.each do |reason| reasons << Reason.find_or_create_by_content(reason) end end
2006 Jun 19
2
const_missing error of has_many through association
Hi, I am new to ruby on rails. I am building an association join model and encountered the following error. Does anyone know what am I missing? > NameError in StartController#home > >d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:100:in `const_missing'': uninitialized constant Membership I have the following tables relationships Users
2009 Nov 12
0
Problem with has_many :through, :uniq => true with polymorph
Didn''t have quite enough space to describe it there...basically i''m having a problem with the :uniq option in my tags. I''m using acts_as_taggable_on_steroid which adds these associations to my Resource class: Resource has_many :taggings, :as => :taggable, :dependent => :destroy, :include => :tag has_many :tags, :through => :taggings, :uniq => true
2011 Aug 17
1
has_many :through, collection<<(object) and duplicates.
Hi, I''m facing a strange behavior in Rails with the has_many association and the generated collection<<(object, ...) method that comes along. I''ve got an Object model and a Tag model, plus a taggings table to join the two together. On Object, I set these associations: has_many :taggings, :as => :taggable, :dependent => :destroy has_many :tags,
2007 Oct 18
0
Getting the through items from a has_many :through :uniq relationship
Getting the through items from a has_many :through :uniq relationship In a nutshell, I have been using the has_many :through :uniq relationship, and I want a DRY way to list the join model objects. Currently, my objects include taxon objects, toxin objects, data_object objects, and taxon_toxin_citation objects ("citation" is another word for data_object). A taxon has many data objects,
2009 Apr 12
0
rails 2.3 nested forms with has_many through checkboxes
I was wondering if anyone knew of a way to combine the new nested forms in rails 2.3 with a has_many through relationship via checkboxes. Basically I have a page model, a page_category model and a category_items join table. Pages have many page categories through category items. The category_items table is polymorphic so i can use it for other models who need categories (maybe this is
2007 Nov 22
1
has_many :through questions
I''ve created the following associations using :through: class Person < ActiveRecord::Base has_many :attendees, :dependent => :destroy has_many :events, :through => :attendees, :uniq => true end class Event < ActiveRecord::Base has_many :attendees, :dependent => :destroy has_many :people, :through => :attendees, :uniq => true
2013 May 22
3
rails 4, active record: appending to has_many :through does not create join model anymore?
hi folks. on rails 4, can somebody confirm that pushing model instances onto a has_many :through relation does not create the necessary join model anymore? class Reader < AR::Base belongs_to :post belongs_to :person end class Post < AR::Base has_many :readers has_many :people, through: :readers end @post.people << Person.new so,
2006 Apr 03
0
has_many questions
My application has two models I''d like to have multiple join tables between, Users and Groups. Users have the ability to subscribe to a Group, while a Group would like to know its membership. Additionally, a User can administer several Groups and a Group should know about its several Administators (Users). I have the following declarations: class Administrator <
2008 Apr 21
1
Urgent ActiveRecord has_many Problem - Please Help
Hi Guys, I''ve been looking everywhere for an answer to this but so far without success. I have three models: 1) employees has_many :memberships has_many :projects, :through => :membership 2) projects has_many :memberships has_many :employees, :through => :membership 3) membership belongs_to :employees belongs_to :projects Membership is used to join employees
2008 Apr 24
2
Dynamic finders in has_many associations
I have these 3 models. class Ivr < ActiveRecord::Base has_many :klusterings, :dependent => :destroy has_many :klusters, :through => :klusterings, :uniq => true end class Kluster < ActiveRecord::Base has_many :klusterings, :dependent => :destroy has_many :ivrs, :through => :klusterings, :uniq => true end class Klustering < ActiveRecord::Base belongs_to :kluster
2006 Dec 05
4
has_many with :uniq not working for me
Hi all, I have a relationship (no really!) class RiskMatrix < ActiveRecord::Base has_many :severities, :order => :position, :uniq => true end class RiskFactor < ActiveRecord::Base belongs_to :risk_matrix validates_presence_of :descriptor, :example validates_uniqueness_of :descriptor, :example, :scope=> :risk_matrix_id end class Severity < RiskFactor
2009 Jan 22
0
ActiveLdap belongs_to and has_many associations
Hi, I am trying to use ActiveLdap for authentication in my rails app. But I am running into a problem with the "belongs_to" and "has_many" associations. Here ist how my models look like. class Person < ActiveLdap::Base ldap_mapping :dn_attribute => "uid", :prefix => "ou=People", :classes =>
2007 Apr 29
1
better nested set and :through
Hello all, It''s been a while since i''ve been doing any rails development, so i''m a bit rusty. Having found this: http://opensource.symetrie.com/api/better_nested_set/ it looks really interesting and useful for solving something i''m trying to get working. What i have (essentially) is the following models: class Group < ActiveRecord::Base
2006 May 10
7
has_many :through scope on join attribute
Hi I have a has_many :through. It''s a basic mapping of Project id .... User id .... TeamMembers project_id user_id role What I would like to do is have different roles so I can have in the project model has_many :core_members, :through => :team_members, :source => :user but I would like to limit this to only those with the "core" role in the team members table for
2008 Sep 16
3
has_one :through eager-loading problem
I have a problem with the :include option in find for my has_one :through association. I have Users, Profiles and Customers, all connected to each other with a has_one :through => :membership association like this: class Profile < ActiveRecord::Base #could also be user or customer has_one :membership # i saw an acrticle of Ryan about has_one :through, there this would be has_many, is
2009 May 12
4
has_many :through and scopes: how to mutate the set of associated objects?
I have a model layer containing Movie, Person, Role, and RoleType, making it possible to express facts such as "Clint Easterbunny is director of the movie Gran Milano". The relevant model and associations look like this class Movie < ActiveRecord::Base has_many :roles, :include => :role_type, :dependent => :destroy has_many :participants, :through => :roles, :source
2006 Mar 24
2
Change to has_many :through associations
Hi everyone. I''ve made a default change to has_many :through associations that I felt was important to make before they''re released. This is after some tickets and confusion I''ve seen regarding has_many :through. class Connection < ActiveRecord::Base belongs_to :user belongs_to :channel end class Channel < ActiveRecord::Base has_many :connections
2006 May 26
3
Breakdowns in has_many abstraction
I discovered an interesting aspect of has_many behavior that I''m struggling to work around. I''m not sure if I''m doing something wrong, or if it''s a legitimate bug, or if it''s an inherent part of Rails that I just have to learn to deal with. It boils down to these two problems: - changes in collection objects (i.e. models that belong_to a container