similar to: Polymorphic has_many association through a belongs_to

Displaying 20 results from an estimated 6000 matches similar to: "Polymorphic has_many association through a belongs_to"

2011 Jan 11
0
[PATCH] Polymorphic belongs_to association with :conditions issues
Hey all, Could use a few eyes on a couple of very simple patches at https://rails.lighthouseapp.com/projects/8994/tickets/6262 if any has some time. The issue (from the ticket description): If you define a polymorphic belongs_to association and it has conditions on it, those conditions cause a NameError when you try to access the target object, of the style saying "hey, there''s no
2006 Aug 16
1
Naming rights_roles join model using has_many :through and polymorphic associations
Hi. I have a couple of best practices questions regarding polymorphic associations, naming join tables and user permissions. Currently I have implemented the user authentication model from the rails recipes book. Basically it goes something like this: MODEL CLASSES: class User < ActiveRecord::Base has_and_belongs_to_many :roles end class Role < ActiveRecord::Base
2006 Mar 19
2
Multiple polymorphic belongs_to declarations
I have the following models: class Card < ActiveRecord::Base belongs_to :deck belongs_to :front, :polymorphic => true belongs_to :back, :polymorphic => true end class TextContent < ActiveRecord::Base has_one :card, :as => :front has_one :card, :as => :back end The conflicting has_one declarations don''t work. What I need is
2010 Apr 10
1
accepts_nested_attributes + polymorphic association
im having an issue where my my polymorphic associations arent being deleted when using accepts nested attributes there are other accepts_nested_attributes being used and they are deleting fine, just the polymorphic association before i go down the path of intense thrashing at this...is this a known issue or problem? -- Posted via http://www.ruby-forum.com/. -- You received this message because
2006 Apr 17
0
polymorphic association with single model as target
Hi, I''m new to rails/ruby and not a sw programmer in the first place. I''d like to use polymorphic associations to create tags/marks into several dictionary tables (i.e japanese to english and japanese to french) that share the same model. In that model I introduced a :target field to select the database in a find query, i.e: def self.find(*args) for i in args if
2011 Jul 08
0
Looking for Help/Advice on StackOverflow Question - Polymorphic Association with STI
I am having trouble with an many to many polymorphic association with STI involved. The problem is described clearly in the following StackOverflow question, so I will leave this thread short: http://stackoverflow.com/questions/6582074/activerecord-has-many-through-polymorphic-associations-with-sti I am posting here hoping to get advice/direction/a solution for this, as I''ve so far been
2010 Mar 01
0
undefined method for Polymorphic association using Searchlogic
I am unable to call a polymorphic scope using the searchlogic plugin as it keeps on returning ''undefined method''. I am certain it is only a problem within my project as I created a test project and I was able to call a polymorphic scope using the searchlogic plugin. I am hoping someone can provide a suggestion on how to debug this issue. My project consists of several gems, and
2007 Dec 20
0
polymorphic has_many :through Vs Inheritance
Hi everyone. Ive part of a project that I need to refactor, and im having some difficultly deciding which path to take. Perhaps someone can help, I think its primarily a design question. A Spec consists of many Nests and many Parts. Nests contain Parts. Here''s what I have, which works well currently: --------------------------------------------------- class Spec <<
2006 May 05
2
Dumb polymorphic association question
Hi, Why is it that polymorphic associations only work with the :has_many and :belongs_to relationships? Why can''t it be a :has_one? Matt
2010 Oct 07
1
Question on polymorphic association
I have 3 models . Doctor, Patient and User with following associations class Doctor < ActiveRecord::Base has_many :patients, :dependent => :destroy has_one :user, :as => :userable accepts_nested_attributes_for :user end class Patient < ActiveRecord::Base belongs_to :doctor has_one :user, :as => :userable accepts_nested_attributes_for :user end class User <
2006 Apr 21
3
polymorphic,has_many through can not work?
Josh Susser tells in his blog that the opposite direction of polymorphic will get into trouble together with has_many through. This is the url: http://blog.hasmanythrough.com/articles/2006/04/03/polymorphic-through I do that according to Josh Susser''s procedure: class Tagging < ActiveRecord::Base belongs_to :tag belongs_to :taggable, :polymorphic => true belongs_to
2006 Mar 26
0
Eager loading and polymorphic association
Hi all, Is it possible to do "eager loading" with polymorphic associations ? Ex : I have a Page model that acts as taggable. When I do Page.find(:all), I would like to retrieve all tags associated with a page. Thanks, Thomas. -- Posted via http://www.ruby-forum.com/.
2012 Sep 08
3
Polymorphic has_and_belongs_to_many association
Hi, I''m currently having the situation where I have to implement a polymorphic has_and_belongs_to_many by introducing an in between model that handles all the "has_many :as" and "belongs_to :polymorphic" association implementations... and is not doing anything else. Thing I don''t like it here is, I am unnecessarily loading AR instances only to execute SQL
2011 May 03
2
Database performance for polymorphic associations under high load
Hey guys, I''ve been thinking lately about polymorphic associations, and I wonder: is there a noticeable or tangible performance "hit" from doing polymorphic associations when you''ve got your database under really high query load? So for example, maybe I have a "message" model, a "user" model and an "administrator" model, without any
2009 Nov 01
1
please help - complicated polymorphic association
I am trying to build a shared-appointment system, where users can subscribe to appointments and be updated whenever changes are made to them. I have three objects in this system, appointments, users, and subscribers. Subscribers are a polymorphic object like so: class Subscriber < ActiveRecord::Base belongs_to :user belongs_to :subscribable, :polymorphic => true end The tricky part is
2006 Jul 26
3
Polymorphic Association with Single Table Inheritance?
Hello, is it possible to setup a model/table schema like this: Groupable --> Membership <-- Group ^ ^ | | User UserGroup I tried the following but failed: Groupable (table with ''type'' column) has_many :memberships, :as => :groupable has_many :groups, :through => :memberships
2006 May 21
3
has_many :through with a polymorphic join
Hi, Four tables: users, user_counties, uk_counties and us_counties. Each user has many counties, and each county has many users, so I decided to make user_counties a polymorph, so it can have counties from different countries (each country requires a completely different set of tables with a completely different set of properties, that''s why there''s one table for uk_counties and
2008 Jun 12
1
unidirectional belongs_to polymorphic
The setup: class Location::Base < ActiveRecord::Base set_table_name :locations ... end class Location::Address < Location::Base ... end class Location::Airport < Location::Base ... end class Person < ActiveRecord::Base belongs_to :location, :polymorphic => true, :class_name => "Location::Base" ... end I want a unidirectional belongs_to relationship. That
2012 Jan 18
2
Polymorphic and standard association issue
Hello all, I''m having a strange issue with a model that belongs_to two other models. The one association is polymorphic and the other is normal. ================================ class Role < ActiveRecord::Base belongs_to :user belongs_to :permission, :polymorphic => true end class User < ActiveRecord::Base has_many :roles has_many :programs, :through => :roles end
2006 May 18
0
Sorting Polymorphic Associations
Recently, I converted a single table inheritance design over to polymorphic associations as that made a lot more sense from a database perspective. One of the features of the ui, a drag and dropable list of items, needs to be completely reworked though. Instead of having one table with a "sort" column, I have 1 polymorphic table "items" acting as a pointer to 3 or 4 other