similar to: Inheritance problem in model

Displaying 20 results from an estimated 6000 matches similar to: "Inheritance problem in model"

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 class who''s only attributes are its
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:
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
2006 Jul 24
1
Newbie error: undefined local variable or method
When I add an item to the shopping cart, I get an error: undefined local variable or method `cart_item'' for #<#<Class:0x3715a78>:0x3715a48> Session info says the cart being updated properly. I''m just not able to output two variables: <%= cart_item.quantity %> &times; <%= h(cart_item.title) %> I did some research, and I can grasp that local
2006 Jan 09
1
Saving an upload
I am creating a database for movies (films) and television shows (shows) that will have has_and_belongs_to_many relationships with the pictures table. CREATE TABLE screenshots ( id serial NOT NULL, filename character varying NOT NULL, content_type character varying NOT NULL, primary key (id) ); CREATE TABLE films ( id serial NOT NULL, name character varying NOT NULL,
2006 Aug 04
6
Errors ... errors and errors.
I bought the second edition of the ruby on rails, it seems to work fine now, did some adjustments to the code. But now I get a second error and I want to learn to understand to fix them myself. So here is the error. ArgumentError in StoreController#add_to_cart wrong number of arguments (1 for 0) #{RAILS_ROOT}/app/models/cart.rb:15:in `initialize'' #{RAILS_ROOT}/app/models/cart.rb:15:in
2007 Sep 04
4
Could someone take a look at #9477 (new fieldset_tag helper)?
Hi everyone, I just submitted a patch for a new fieldset_tag helper. It''s helpful and encourages developers to follow web standards, etc. "+1"s welcome :-) http://dev.rubyonrails.org/ticket/9477 Cheers Damian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
2010 Nov 05
4
Inheritance alternative
I have to objects with common functionalities and a lot of difference. So I want that each have his own table but inherit the common functionalities from a parent class. How can I do this 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
2006 Jul 13
5
ActiveRecord inheritance
How to create a super class based on ActiveRecord::Base? For example: class ParentRecord < ActiveRecord::Base end class ChildRecord < ParentRecord end Rails always asks for ''parent_records'' table. Which has absolutely no need to exist at all. It''s intentionally made as a super class to be inherited. Thanks. -- Posted via http://www.ruby-forum.com/.
2009 Jul 21
1
[RAILS] - 2.3.3 creating a sea of red
hello, I''ve already asked via Rails channels on this and have received no response, so I''m asking here in hopes someone has run into something similar. I updated to rails 2.3.3 yesterday, and now all of my specs are failing with the following error: Fixture::FormatError in ''PublishedGallery Methods#thumbnail should delegate to its lead asset'' a YAML error
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
2007 Feb 06
4
Inheritance design question
I''m new to ruby rails and am trying to design my first real rails web app. The app is intended to model a shareware business. It will provide a place where users can learn about new projects, track their progress, and provide feedback. Here''s a simplified list of the model objects that I''ll need: Project - has title, description, creation, modification. Release - has
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 Jan 11
1
Composite primary key
Hi All, How do I specify a composite primary key for a table in ActiveRecord? For example the table Recipe which has the primary key [cookie id, version number] where cookie id is also a foreign key referencing Cookie. Also: Thanks to Nic and Adam for helping with the Cookie -> Cooky problem. /Hugo --SQL * CREATE* *TABLE* `Raw_Materials`* (* id *INT*
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 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/. --~--~---------~--~----~------------~-------~--~----~ You
2005 Dec 23
4
OO model style: inheritance
Hi everybody I am totally new to rails and I am trying to start a tiny project to get familiar with rails. But I already got my first problem and I would be happy if somebody could point me in the best and cleanest direction. I am trying to develop a small gallery app. Since I would like to add more features in future I am trying to design a clean OO architecture of my models: The base object
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