search for: abstract_class

Displaying 20 results from an estimated 36 matches for "abstract_class".

2007 Oct 12
6
abstract_class... what exactly does it do
Hi, Does anyone know much about abstract_class? Does it actually prevent instances of the class from being created? Does it disable certain methods? I already know what it''s for, but I want to know what setting self.abstract_class=true actually does. The reason I ask is that I want to use it for a slightly unorthodox purpose. I want a...
2006 Aug 24
0
Model with self.abstract_class=true allows save method call
I think this is a bug. I declared a model with self.abstract_class = true and then tried to call save on it and it attempted the save. I think this should raise a "method not allowed" exception of some sort. Where is the Trac system that I would use to report this? Thanks, Wes -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~----...
2012 Jul 25
0
Rails3-default_scope throws exception: undefined method abstract_class? for Object:Class
...f inactive update_attribute(:available, false) end default_scope :available => true end Getting following error when add the default_scope */gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/base.rb:1212:in class_of_active_record_descendant'': undefined methodabstract_class?'' for Object:Class (NoMethodError)* -- 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...
2007 Sep 29
8
Inheritance problem in model
...the inheritance as soon as I try to use it in a model. I''ve got plenty of items which can share a lot of code, so I created a class "Item", which inherits from ActiveRecord::Base, but because it''s not a "real item" but an interface, I set it abstract (writing abstract_class? method). Then I have all the differents items I can use (for instance: book,picture,...) which have their own class. I tried to write it down like : class Item < ActiveRecord::base def abstract_class? true end #stuff end class Book < Item def abstract_class? false end #stuff end The pro...
2008 Dec 09
7
subclassing vs mixins, which one should be used?
Hey all, I have two models in my rails project that share a lot of traits. They each have the same 4 properties, and now I need to add 2-3 methods to each one that will be the same. In the spirit of DRY I am looking for a solution to write these methods only once. Both of these models already inherit from ActiveRecord . . . and I didn''t know if it was safe to just "whip up" a
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
2011 Dec 03
1
ActiveRecord Abstract class
Hi, I was trying to create an abstract class and a subclass which inherit that abstract class. However, seems like I cannot instantiate the subclass too. Below is my code: //abstractclass2.rb class Abstractclass2 < ActiveRecord::Base self.abstract_class = true end //subclass.rb class Subclass < Abstractclass2 end When I test drive it in rails console, I got the following error: from (irb):1irb(main):002:0> sb = Subclass.new ActiveRecord::StatementInvalid: Could not find table ''subclasses'' from /usr/lib/ruby/gems/1.8/...
2007 May 03
2
How to run a cpu intensive ruby script with rails functionality
Hi All, I am new to this list and to rails. So far I am loving the way in which it is easy to put together web pages with a database backend. I would love to use the rails functionality (to do the sql queries) and then process the results using some very cpu intensuve tasks. The results will take far longer than it is viable to use a web browser to view the results. I would like to see the
2009 Mar 14
9
null object pattern
I am trying to create a null object in my application. I would like to assigned a null user object for anonymous/ mot-logged-in user, i.e. if session variable has nil data. In my User model, I have created a subclass like this: class UnassignedUser < User def save false end def update false end def username "Unassigned" end def county_id
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
2009 Jul 21
1
[RAILS] - 2.3.3 creating a sea of red
...o its lead asset'' a YAML error occurred parsing /Users/mpd/timber/spec/fixtures/ galleries.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html The exact error was: NoMethodError: undefined method `abstract_class?'' for Object:Class A full stack trace (and other info like the list of system gems) is available at: http://gist.github.com/151492 The real problem has nothing to do with YAML. I can go green right now by changing RAILS_GEM_VERSION in environment.rb back to 2.3.2. I''m sure this...
2010 Jan 26
6
Subclassing ActiveRecord::Base
First of all, sorry for the crossposting, but I put this into the Ruby Forum first of all, but was pointed to this as a more appropriate location. I''m using ActiveRecord and ActiveSupport in a non-rails environment to connect to multiple databases, and I''ve found the following (single database) to cause me an error. Note that params is my database settings and omitted for
2006 Jun 26
1
Separate Read and Write Database
Hello, I need to access an mirrored database with one read and one write cluster. Is there a way to tell a model to use two connections? So that all updates etc go to the write database and all read from the read one? This is a fixed set up I can not use MySQL 5.x stuff and additionally i get a token on write, which can be checked on read (and wait for replication) if new data is needed. I
2006 Oct 12
2
Too Many Mysql connections
In my app, for three models: foo,bar and baz, the database connection is made to a different database and hence in model code: class Foo < ActiveRecord::Base establish_connection :diff_database end class Bar < ActiveRecord::Base establish_connection :diff_database end class Baz < ActiveRecord::Base establish_connection :diff_database end Now, the problem is, if is use the above
2006 Jul 26
4
Execute code when an inheritance happens, or disabling STI
I am trying to inherit from a ActiveRecord class defined in a plugin. The problem is that ActiveRecord thinks I am doing an STI and is looking up a table that doesn''t exist. Currently, I have a method in the parent class that looks like this: def self.fix_table_name class_eval do set_table_name(Inflector.tableize(self.to_s)) end end The problem is that this method
2009 Mar 17
11
Refactoring module
Dear all Please see the following module, In module SX3 SX4 and SX5 have similar class Tasklist, but inherit from different class. I will use the following code to connect to different data sources RemoteSX3Model.establish_connection sx3_hash RemoteSX4Model.establish_connection sx4_hash RemoteSX5Model.establish_connection sx5_hash How can I refactor my code in module to look simpler? Thank you
2007 Oct 24
6
how to subclass active record to call a method on all save and destroy actions
I''m looking for a way to subclass active record (I''ll refer to the subclass I want to create as NewActiveRecord) so that I can call different methods on a save or destroy action on all models which sub class NewActiveRecord I dont want to use before_save or any of the other regular call back methods as I want to be able to use these call backs in the models which subclass
2006 May 08
4
Tables names with model classes in seperate modules
I have a module that deals with content pages and categories in my application so create following tables: content_pages content_categories Obviously I need a Page and Category module to map to these tables, but in order to avoid conflicts with other Category classes, i declare my model classes like this: Content::Page Content::Category Now, that''s all fine - except that my models
2012 Mar 02
0
ConnectionNotEstablished when using connection on AR::Base abstract subclass
I''m using AR outside of Rails and calling establish_connection on an ActiveRecord::Base abstract_class subclass (to protect my connection in case anyone else is using AR). It was working just fine with AR 3.0.9, but I recently attempted to upgrade to AR 3.2.2. Now, when I hit a "nested" query from a has_many, I get a ActiveRecord::ConnectionNotEstablished. If I call establish_connection...
2010 Sep 17
6
Rails base model
I''m very new to Ruby and to Rails. I''m coming from PHP and CakePHP. I would like to create a base model from which all other models will inherit from. I have done this: class AppModel < ActiveRecord::Base end and class Post < AppModel end I''m getting the following error: Table ''blog_development.app_models'' doesn''t exist My