Hi all,
I have a basic model as follow, but when I try to query the database, I
get the following error:
''wrong number of arguments (0 for 2)''
I don''t see any problem, I am becoming crazy o_O''
Migration
---------
class CreateSubtasks < ActiveRecord::Migration
def self.up
create_table :subtasks do |t|
t.string :hostname, :type
t.integer :task_id
end
end
def self.down
drop_table :subtasks
end
end
Model
-----
class Subtask < ActiveRecord::Base
belongs_to :task
end
Code causing the error
-------------------------------
This doesn''t work: Subtask.find(:all)
This work: @toto = Subtask.new
I can add subtasks but not query them :S
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
> Migration > --------- > class CreateSubtasks < ActiveRecord::Migration > def self.up > create_table :subtasks do |t| > t.string :hostname, :typeIt seems that :type should not be used as a column name. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Robert Walker
2008-Sep-29 13:07 UTC
Re: [ActiveRecord] wrong number of arguments (0 for 2) ?!
MR Damien wrote:>> Migration >> --------- >> class CreateSubtasks < ActiveRecord::Migration >> def self.up >> create_table :subtasks do |t| >> t.string :hostname, :type > It seems that :type should not be used as a column name.I''m guessing that this (from ActiveRecord::Base doc) has something to do with it: ------------------------ Single table inheritance Active Record allows inheritance by storing the name of the class in a column that by default is named "type" (can be changed by overwriting Base.inheritance_column). ------------------------ -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Abhishek shukla
2008-Sep-29 13:09 UTC
Re: [ActiveRecord] wrong number of arguments (0 for 2) ?!
Type is a reserve keyword for single table inheritance. regards abhishek On Mon, Sep 29, 2008 at 5:47 PM, MR Damien <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Migration > > --------- > > class CreateSubtasks < ActiveRecord::Migration > > def self.up > > create_table :subtasks do |t| > > t.string :hostname, :type > It seems that :type should not be used as a column name. > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Reasonably Related Threads
- STI and type tables?
- ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'Transactions::DummyDdnlTransaction'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Pleas
- Newbie - ActiveRecord relationships
- Objects in Arrays? Allowed, right?
- Disabling ActiveRecord "type" column subclassing