similar to: Polymorphic naming difficulties

Displaying 20 results from an estimated 2000 matches similar to: "Polymorphic naming difficulties"

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 May 24
0
polymorphic url and polymorphic partial helpers
Here are a couple of articles I wrote describing a couple of handy helpers for dealing with polymorphic objects. These helpers allow you to generate urls and render partials on objects without knowing what class they are ahead of time. http://www.sciwerks.com/blog/2006/05/24/polymorphic-urls/ http://www.sciwerks.com/blog/2006/05/24/polymorphic-partials/ Hopefully you will find them useful.
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 10
2
Polymorphic associations in reverse?
My app has an association that''s got me scratching my head. I have Users, and Images. A User has many Images. (Yes, another picture sharing app, but it''s for a small niche, and it doesn''t end in -r!) I would like to express a "Favorite" relationship between both Users to Users, and Users to Images. This seems like the opposite of the standard
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
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
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
2009 Jul 20
0
Polymorphic Comment notification to Users?
Hi, my webapp has registered users and it has articles, blog posts, gossips too. For all these resources I''ve a polymorphic Comment model which is listed below. <pre> id content commentable_id commentable_type user_id created_at updated_at 1 Frist comment 2 Article 1 .... 2 Second comment 3 Post 2 .....
2007 Jan 19
0
Do transactions fail with polymorphic has_one relationships?
I have an AR::Base descendant with a complex object graph beneath it, like so: ArtisanQuoteInput has_one QuoteInput and then QuoteInput has several objects attached to it. Note that the relationship between ArtisanQuoteInput and QuoteInput is polymorphic, so the relationship in A is written has_one :quote_input, :as => :program_quote_input If @artisan_quote_input is an instance of
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 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
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
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 Sep 22
2
possible to create polymorphic relationship with STI models?
I would like to associate a ‘product’ model with 3 models inherited from ‘image’: part, action and accessory. I have it working with Has_many :through relating products to images through attachments, I then have to determine the ‘type’ of the STI extension. This means i have to go product.images. While this is ok, i can see it getting tricky when i want to go products.images <<
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
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
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
2007 Aug 23
0
active scaffold polymorphic model
Hi I am trying to use active scaffold to build a polymorphic model . I have a number of models that can be featured and I have a Feature model that belongs_to :item, :polymorphic => true In my config.columns I include :item_type and item_id, I also added :item_name to show the name of the record in the form. In the form, when a type of model is selected I populate the select box for
2009 Oct 05
0
ActiveRecord Polymorphic Inheritance
I am using RoR ActiveRecord polymorphic inheritance and was wondering if it''s possible to access the base class'' association methods in the invocation of either to_xml or to_json without having to depict the base class data in the serialized string. Here are my classes: # base class class Asset < ActiveRecord::Base belongs_to :resource, :polymorphic => true