# \[ActiveRecord\] wrong number of arguments (0 for 2) ?!

**URL:** <https://www.ruby-forum.com/t/activerecord-wrong-number-of-arguments-0-for-2/149760>\
**Category:** Rails\
**Created:** [September 29, 2008, 2:14pm UTC](https://www.ruby-forum.com/t/activerecord-wrong-number-of-arguments-0-for-2/149760 "2008-09-29T14:14:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrdamien](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mrdamien](https://www.ruby-forum.com/u/mrdamien)\
**Post date:** [September 29, 2008, 2:14pm UTC](https://www.ruby-forum.com/t/activerecord-wrong-number-of-arguments-0-for-2/149760/1 "2008-09-29T14:14:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mrdamien](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mrdamien](https://www.ruby-forum.com/u/mrdamien)\
**Post date:** [September 29, 2008, 2:17pm UTC](https://www.ruby-forum.com/t/activerecord-wrong-number-of-arguments-0-for-2/149760/2 "2008-09-29T14:17:17Z")

</div>

> ## 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.

---

<div class="post-metadata">

**Author:** ![mrdamien](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mrdamien](https://www.ruby-forum.com/u/mrdamien)\
**Post date:** [September 29, 2008, 3:07pm UTC](https://www.ruby-forum.com/t/activerecord-wrong-number-of-arguments-0-for-2/149760/3 "2008-09-29T15:07:28Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![mrdamien](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mrdamien](https://www.ruby-forum.com/u/mrdamien)\
**Post date:** [September 29, 2008, 3:10pm UTC](https://www.ruby-forum.com/t/activerecord-wrong-number-of-arguments-0-for-2/149760/4 "2008-09-29T15:10:13Z")

</div>

Type is a reserve keyword for single table inheritance.

regards  
abhishek

On Mon, Sep 29, 2008 at 5:47 PM, MR Damien  
\<removed\_email\_address@domain.invalid
