similar to: Polymorphic associations in reverse?

Displaying 20 results from an estimated 1000 matches similar to: "Polymorphic associations in reverse?"

2008 Jun 13
1
Polymorphic :through associations
Could someone please help me with this association scheme? I am familiar with habtm as well as the :through association but this one has me stumped. Here is an example DB. Tags Table: ------------------------- id name Taggables Table: -------------------------- id tag_id taggble_type taggable_id For purposes of this example say that there are 2 other tables that can be tagged and their model
2006 Apr 06
0
How to use polymorphic in a beautiful way in such a case?
class User<ActiveRecord::Base has_many :taggings, :as=>:taggable,:dependent=>true has_many :tags,:through=>:taggings end class Article<ActiveRecord::Base has_many :taggings, :as=>:taggable,:dependent=>true has_many :tags,:through=>:taggings end class Tagging<ActiveRecord::Base belongs_to :tag belongs_to :taggable,:polymorphic=>true end class Tag<ActiveRecord::Base
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
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
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/.
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
2006 Jul 26
1
Polymorphic Associations: dynamic finders
Is there any sort of dynamic finder for polymorphic associations? For example if I had: class InviteNode < ActiveRecord::Base belongs_to :inviteable, :polymorphic => true end I would like to be able to search by: InviteNode.find_by_inviteable(some_object) instead of having to do: InviteNode.find_by_inviteable_id_and_inviteable_type(some_object.id, some_object.class.name) obviously I
2006 Mar 31
2
Eager loading of polymorphic associations
Polymorphic associations work great until I try to do some eager loading through :include. In my example, the interface name is ":imagehaver". Here''s my little eagerly loading find line: Image.find(params[:id], :include => :imagehaver) All it gives me is an ActiveRecord::EagerLoadPolymorphicError with no further explanation. I haven''t been able to dig up anything
2008 Apr 11
1
polymorphic associations wrong when used with inherited class?
Consider the following: class Event belongs_to :event_object, :polymorphic => true end class Asset < ActiveRecord::Base end class EventedAsset < Asset has_one :event, :as => :event_object end EventedAsset.find(:first).event generates the following SQL: SELECT * FROM `events` WHERE (events.event_object_id = 1 AND events.event_object_type = ''Asset'') LIMIT 1
2006 Feb 10
3
[Req] polymorphic associations howto
Hi people, I''m looking into polymorphic associations as a way to cleanup some messy parts of my code. I think they will allow me to do exectly what I need, but since there''s little to none written on this subject, I''d be delighted if someone could shed some light on this. Especially what the different options and needed table structures need to be. Thanks, -
2007 Jan 27
1
Polymorphic Associations or not
Hey, I am starting my store application again for the 3rd time, I am just trying to get eveything right so that I don''t come up with any more complex problems later. Hopefully someone can steer me in the right direction. I have a store that sells lots of types of product. e.g. CDs, T-Shirts, DVD Each product type has different associations. Cds - multiple artists, multiple genres,
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
2008 Jan 04
1
eager loading and polymorphic associations
There is a dedicated section about eager loading in the docs. A coworker discovered eager loading does not work in polymorphic associations the hard way :-) so I''ve written a patch that documents it: http://dev.rubyonrails.org/ticket/10610 There are at least a couple of tickets that implement something that would change that though: http://dev.rubyonrails.org/ticket/9640
2007 Oct 27
0
STI vs Polymorphic Associations
I have a MasterEvent model. It has attributes that is required by another model Event. The user selects the MasterEvent model and I create the Event model by merging the attributes of the selected MasterEvent with the attributes that were presented for the Event model in the form. I have association declarations in the MasterEvent and Event models. If I use STI does the subclasses inherit the
2006 Sep 17
0
[RFC] Nested Restful Resources + Polymorphic Associations
hi, how to handle the problem addressed in this thread: http://rails.techno-weenie.net/question/2006/9/6/nested-restful-resources-polymorphic-associations is there any consensus on this? any comments, suggestions? thanks, _c -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google
2008 Oct 06
0
Mistaking with polymorphic associations?!
Hello, I''m trying to solve a problem without success. Look at: I have 3 models (Recipe, Comments and User) an Recipe has many Comments an User has many Comments an User has many Recipes I tried to implement this using polymorphic associations with the Comment model. But the expected behavior needs to be: When a new comment is created i need to refer it in Recipe and Comments. To
2008 Apr 23
2
Bug in eager loading and polymorphic associations?
Hi friends, i''m usgin the edge version because i need eager loading on polymorphic associations support, but i see this: Message.find(:first, :include => :owner) #This generate this query: SQL (0.000072) SET SQL_AUTO_IS_NULL=0 Message Load (0.000389) SELECT * FROM `messages` User Load (0.001070) SELECT * FROM `users` WHERE (users.id IN (1,2)) And this Message.find(:first,
2006 Mar 23
5
Polymorphic associations
I have just updated rails and added polymorphic associations but they are not working properly. I''m following the recipe 17 of "Rails Recipes" and I''m getting an "Unknown key(s): as" error. These associations work properly on the console. The problem occurs when I''m listing the items... perhaps the problem is pagination. Is this a bug or what
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 Aug 16
0
Polymorphic Associations and grouping users and projects
Hi all, In my app I would like to create user groups in my admin. Currently I have the following models and associations that facilitate this. class User < ActiveRecord::Base has_many :memberships has_many :groups, :through => :memberships end class Membership < ActiveRecord::Base belongs_to :group belongs_to :user end class Group < ActiveRecord::Base has_many