Displaying 5 results from an estimated 5 matches for "descends_from_active_record".
2006 Feb 07
4
Ruby, Rails & Inheritance
...ollowing problem:
Some of my models share some attributes and also was in need for some
extra features, so I created a class "RecordWithFeatures":
-----------------------------------------------------------------
class RecordWithFeatures < ActiveRecord::Base
# @Override
def self.descends_from_active_record?
superclass == RecordWithFeatures
end
# @Override
def self.class_name_of_active_record_descendant(klass)
...
end
...
end
class SomeModel < RecordWithFeatures
...
end
-----------------------------------------------------------------
Ok, everything works fine, but I would al...
2006 Nov 21
5
acts_as_ferret with STI models
Can acts_as_ferret search only one of the inherit models in the
hierarchy of STI models? Say you have Contents, with types articles and
comments. I know that you do Contents.find_by_contents, but can you
also create indexed for Comment and Articles?
Thanks for you help
Miguel
--
Posted via http://www.ruby-forum.com/.
2011 Apr 15
2
sti + namespace
....rb
apps/models/weather_stations/cwop.rb
apps/models/weather_stations/wolfram.rb
... etc.
So: are there any special considerations in this approach? The docs
talk about namespacing models, and talk (briefly) about STI, but not
together. Do I have to do anything special with table_name_prefix or
descends_from_active_record? ?
I''ll set about trying this out as soon as I hit [submit], but I''d
appreciate a heads up if I''m headed for trouble!
TIA.
- ff
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rail...
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
2004 Nov 19
18
SingleTableInheritance Considered Harmful
...o another. I
don’t want to have to add the connection code to every single Active
Record subclass I create when I could consolidate it into two abstract
classes.) Or you will be once you convince Active Record to ditch the
inheritance:
class MyActiveRecord << ActiveRecord::Base
def self.descends_from_active_record?
true
end
end
Or, if you still don''t understand relational databases and insist
on using Single Table Inheritance, but still need an abstract class
between you and Active Record, you can
def self.descends_from_active_record?
superclass == MyActiveRecord
end