similar to: Polymorphic Associations

Displaying 20 results from an estimated 1100 matches similar to: "Polymorphic Associations"

2008 Jan 21
13
has_many with different primary key
I''ve got quite the ActiveRecord challenge, any help would be appreciated. In my current project Companies can have many reviews. class Company < ActiveRecord::Base has_many :reviews, :as => :reviewable end However, my company table, I have two different IDs to identify my company. id - This is the typical id we use for normal stuff other_company_id - This is the id we use
2007 Sep 23
9
Code reviews: my dumb use of acts_as_commentable (newbie)
With the help of several heroes here yesterday I beat my way into a working solution to adding comments to one or more models in my application using acts_as_comentable. Great plugin, but my implementation is lame. I need enlightenment. I have users who log in. For several views I want to let them add comments. Enter act_as_commentable which does just this -- it''s polymorphic, so you
2006 May 01
2
Getting my schema straightened out
I''m trying to map Rails to an existing schema, and having a bit of a time of it. I''ve got a table Content, and I''ve got a table Review, which is a type of content. So content has an ''id'' field, and Review has a ''contentid'' field. Not all Content has a Review, but all Reviews have exactly one Content. How do I represent this?
2006 Feb 08
1
Adding children via small subform
I''ve read AWDR and especially the part concerning adding child line_items to an order. Unfortunately I want to do my process in reverse and in doing what I thought would work I get a null object error when trying to append the children to the parent. This is a _major_ stumbling block in my Rails use as almost every one of my projects has needed this so its a pretty vital problem I need
2017 Aug 24
2
Dovecot - Postfix Calender Synchronisation
RG> Re: portable formats and their mime type RG> https://en.m.wikipedia.org/wiki/ICalendar RG> https://en.m.wikipedia.org/wiki/VCard RG> Re: dependencies RG> - db: why? just use the ical and vcard files! They are files, RG> they are in a directory, they can be used like dovecot uses eml RG> files! No need for postgresql or mysql. RG> - webmail: why? We use dovecot!!!
2020 Sep 16
4
[cfe-dev] Phabricator -> GitHub PRs?
Uh-oh: Failed to publish: GitHub error 404 on POST https://api.github.com/repos/llvm/mlir-npcomp/pulls/42/reviews: Not Found (The llvm organization may need to authorize Reviewable as an accepted third party application.) Can an admin take the suggested action on the mlir-npcomp project in the LLVM org? I've followed the instructions in this help doc
2011 Oct 10
1
Text Mining with Facebook Reviews (XML and FQL)
Hello, I am trying to use XML package to download Facebook reviews in the following way: require(XML) mydata.vectors <- character(0) Qword <- URLencode('#IBM') QUERY <- paste('SELECT review_id, message, rating from review where message LIKE %',Qword,'%',sep='') Facebook_url = paste('https://api.facebook.com/method/fql.query?query=
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
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
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,