Displaying 20 results from an estimated 10000 matches similar to: "Mistaking with polymorphic associations?!"
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
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 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
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 Feb 09
2
Polymorphic Associations
If anybody on edge familiar with this could help, that would be "great" :)
I have different types of things I want to be "reviewable". So, instead of
having a slew of HABTM... this new Polymorphic Associations schtick seemed
like the best solution. I have everything setup as I thought it should be
(so I think)... but it doesn''t appear to be working correctly. Here
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
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
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
2007 Nov 04
2
Xen Network Problems
Hi all:
I installed xen-3.0.4 on Fedora 7, and installed Fedora 6 as DomainU, but,
the network can not work normally. It only work for seconds, then I lose
connect. If I ifdown the NIC and ifup it, the network can work for a few
seconds, Can anybody help me figure what''s the problem ??
Thank you in advance
_______________________________________________
Xen-devel mailing list
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,
2008 Apr 21
2
Eager Loading Polymorphic Associations
Hi,
I''m searching for a method of eager loading polymorphic associations under
activerecord 2.0.2. After some initial google-fu I came up with a link to
an enhancement that''s been added to edge:
http://dev.rubyonrails.org/ticket/8119
Anyone have any idea how long that might take to work its way into a general
release? I''m early in development now so I can afford to
2006 Jul 31
3
Polymorphic associations and single table inheritance
Running into an interesting problem that at first glance appears to be a
bug in the AR association code. However, it''s explicitly coded this way
so I''m not so sure.
I have some code like this:
class Address < ActiveRecord::Base
belongs_to :addressable, :polymorphic => true
end
class Person < ActiveRecord::Base
has_many :addresses, :as => :addressable,
2007 Dec 27
6
ActiveResource and (polymorphic) associations
Hi,
I''m just playing with ActiveResource and I did''nt find anything about
the support of (polymorphic) associations.
Is there a support at all?
Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
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 Mar 24
7
Polymorphic associations?
I''ve read the stuff about polymorphic associations here:
http://wiki.rubyonrails.org/rails/pages/UnderstandingPolymorphicAssociations
But I''m not sure what exactly they are and what their advantage is. Are
they the same as HABTM, but they''re "two-way"?
Joe
--
Posted via http://www.ruby-forum.com/.