Displaying 20 results from an estimated 70000 matches similar to: "Polymorphic Destroy"
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
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 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 <
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 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,
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
2013 Feb 28
2
Create polymorphic resources
Hi
I have created a polymorphic association for comments since I need
commenting functionality on several models. The issue is that when I create
the comment in my Commets#create action, I really don''t know what type the
parent is of.
So, let''s say I have Foo, Bar and Comment. Comment have this:
belongs_to :commentable, polymorphic: true
And Foo and Bar both have:
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
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
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 .....
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 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 <<
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 Jul 22
2
How to build scope for count() & has many polymorphic?
Hello, i have the following models in my application:
class Message < ActiveRecord::Base
has_many :comments, :as => :commentable, :dependent => :destroy,
:order => ''created_at ASC''
end
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
end
I need "commented" named scope, which do the follownig thing:
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
2008 Sep 25
1
defining polymorphic type condition
As great as Rails 2.1 is, I for the life of me cannot figure out why
polymorphic associations do not support reconfiguring the type column
used.
For example, I have no way to do a polymorphic association using a
lookup hash which maps an integer to a class name.
Storing a TINYINT unsigned is waaaaay more efficient than storing a
string like "SomeActiveRecordModel" over and over again.
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 May 07
1
Can't eagerly load a polymorphic association defined in an STI parent class?
If I define an association (in my case a polymorphic one) in an STI
parent class, and try to eagerly load it in a subclass, I get the
following error:
ActiveRecord::ConfigurationError: Association name ''myassoc'' was not
found; perhaps you misspelled it?
If I redefine the same association again in the STI subclass, it
works.
Is this a bug or what?
--
You received this message
2007 Aug 07
0
has_and_belongs_to_many polymorphic question
I''ve got a situation where I''m trying to model the following
relationship:
a ''page'' has multiple lineitems
a ''lineitem'' can be either a ''page'' or a ''entity''
The ''lineitem'' looks like it should be polymorphic but the ''page'' and
''lineitem''
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