similar to: Why does AR use base_class for polymorphic relationship "type"

Displaying 20 results from an estimated 2000 matches similar to: "Why does AR use base_class for polymorphic relationship "type""

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 Jul 05
2
Serialized object behaves weird
Hi! I got a class named EinsatzFilter which I serialized to session. Before saving to session it works afterwards I keep getting the message: "undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from ActiveRecord::Base inherited class. Code: class EinsatzFilter include ApplicationHelper attr_reader :personen, :monat, :projekte, :kunde
2006 Mar 20
3
help: acts_as_versioned setup error "undefined local variable or method ''base_class''"
Hi All, Rails newbie here trying to set up acts_as_versioned according to Chapter 14 in the Rails Recipies book. I''ve taken the following steps (nearly verbatim) as mentioned by the book: - created the target model "Post" - added the "acts_as_versioned" label to the model file - generated a migration file - added the table creation code and the command
2006 Mar 28
12
cached-model broken with Rails 1.1
It looks like cached-model is broken again under rails 1.1. Can anyone confirm? Note that the exception below indicates it''s trying to treat CachedModel as the class name of the model, rather than using the proper class name (which is Entry in this case, and the table called entries). This is a model using Single Table Inheritance and acts_as_tree, and worked just fine under 1.0 and
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.
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
2010 Feb 08
5
Why are double sided polymorphic relationships lacking in Rails?
http://stackoverflow.com/questions/2224994/why-are-double-sided-polymorphic-relationships-lacking-in-rails -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to
2012 May 15
5
setting up the SQLite database
I know this isn''t Python, but I''d like to get a view on the ''one obvious'' way to set up an SQLite (or other) database and its location per-app. I''ve got a bit lost with the Camping 2 changes and various code snippets I have kicking around. 1. is it best to set up the DB creation/connection: 1.1 at the end of the app
2007 Nov 20
2
Plugin: create instance methods dynamically in ClassMethods?
Hi all I have the following plugin code: module IncenseCrud def self.included(base_class) base_class.extend(ClassMethods) end module ClassMethods def performs_incense_crud def index list return render(:action => ''list'') end end end end In init.rb I have the following: require File.dirname(__FILE__) +
2008 Oct 29
5
Polymorphic Associations with inheritance
I have two models, Article and Post, that has many Comments. However, both Article and Post are inherited from a BaseContent class like so: class Article < BaseContent has_many :comments, :as => :commentable end class Post < BaseContent has_many :comments, :as => :commentable end and here''s my Comment model: class Comment < ActiveRecord::Base belongs_to
2012 Mar 22
1
why doesn't .where() honor polymorphism?
I love the query interface (ActiveMethod::QueryMethods), but one thing has bugged me: why doesn''t it generate calls for polymorphic associations? For example: class MyModel < ActiveRecord::Base belongs_to :parent, :polymorphic => true end I would expect: MyModel.where(:parent => a) to be equivalent to: MyModel.where("my_models.parent_id = ? AND
2006 Apr 28
2
file_column with polymorphic table relationship?
Hello, I''m just starting out with both Rails and Ruby, so I hope this isn''t too simple of a question - but I''ve been struggling to find a solution. I''m using the file_column plugin to handle image uploads and thumbnail generation. In addition, I''ve wrapped the image into a polymorphic table so I can have uploaded images associated with multiple
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 Jul 15
2
FieldQuery not returning anything
Hey .. The QueryParser RDoc page explains to me on how to search for a specific value in a specific field. This is not working the way i thought it should be, what am i doing wrong? Here''s an example .. I''m storing model data in the index like this: doc << Field.new( "object_id", object.id, Field::Store::YES) doc << Field.new( "type",
2011 Oct 06
1
[LLVMdev] TableGen For Loops
greened at obbligato.org (David A. Greene) writes: > So here's why I think the for loop proposal can't be a preprocessing > phase. Down in the guts of this I fundamentally need to be able to do > this: > > multiclass blah<list<int> Values> { > for v = Values { > def DEF#v : base_class<v>; > } > } > > Will that work? Is the for
2011 Oct 06
4
[LLVMdev] TableGen and Greenspun
greened at obbligato.org (David A. Greene) writes: > The problem I solved via multidefs was this: how does one write a set of > Pat<> patterns in a generic way? > > For example, I want to be able to do this: > > defm MOVH : > vs1x_fps_binary_vv_node_rmonly< > 0x16, "movh", undef, 0, > // rr > [(undef)], >
2007 Jun 04
1
acts_as_rateable in Beast
I''m trying to implement acts_as_rateable to my Beast installation to give users the option to rate posts (like reddit). I chose acts_as_rateable as it supposedly easily allows reddit-type voting but I''m having some problems setting it up and the documentation seems outdated. (http://www.juixe.com/techknow/index.php/2006/07/05/acts-as-rateable-plugin/) So far, I''ve
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
2008 Feb 21
1
polymorphic has_many from ActiveRecord::Base????
I have a polymorphic thingy called fields and I need to on each and every model, so I''d like to do the has_many from the base class, like this... ActiveRecord::Base.class_eval do has_many :fields, :as => :model, :dependent => true end It fails with this no method error (class_of_active_record_descendant) /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/
2006 Feb 21
6
+ camping/session
Camping now comes with a sessioning class, checked in tonight. To get sessions working for your application: 1. require ''camping/session'' 2. include Camping::Session in your application''s toplevel module. 3. In your application''s create method, add a call to Camping::Models::Schema.create_schema 4. Throughout your application, use the @state