# Problem with plurals, migrations?

**URL:** <https://www.ruby-forum.com/t/problem-with-plurals-migrations/101904>\
**Category:** Rails\
**Created:** [August 8, 2006, 5:00pm UTC](https://www.ruby-forum.com/t/problem-with-plurals-migrations/101904 "2006-08-08T17:00:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [August 8, 2006, 5:00pm UTC](https://www.ruby-forum.com/t/problem-with-plurals-migrations/101904/1 "2006-08-08T17:00:03Z")

</div>

Hi,

Ruby 1.8.4  
Rails 1.1.4  
Windows XP Pro

I’m hitting an issue with migrations that I suspect relates to  
pluralization. Here’s the migration:

class Hardware \< ActiveRecord::Migration  
def self.up  
create\_table :hardware do |h|  
h.column :vendor, :string, :limit =\> 32  
h.column :model, :string, :limit =\> 32  
end

```
  Hardware.create(:vendor => 'Foo', :model => 'Bar')

```

end

def self.down  
drop\_table :hardware  
end  
end

Here’s the model:

class Hardware \< ActiveRecord::Base  
set\_table\_name “hardware”  
has\_many :schedules  
end

When I run the migration the table creation occurs, but then I get this  
error:

– create({:vendor=\>“Foo”, :model=\>“Bar”})  
rake aborted!  
undefined method `create’ for  
#ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x39293cc

My guess is that it was expecting a “hardwares” table instead of  
“hardware”, and is getting confused. But, I didn’t see a method in the  
docs to set the table name ala ActiveRecord.

Or am I missing something obvious here? I checked the docs and Google,  
but didn’t find anything.

Below is the full trace.

Thanks,

Dan

rake aborted!  
undefined method `create' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x39293cc> c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/mig ration.rb:272:in`send’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active\_record/mig  
ration.rb:272:in `method_mis sing' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/mig ration.rb:256:in`say\_with\_t  
ime’  
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/mig ration.rb:256:in`say\_with\_t  
ime’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active\_record/mig  
ration.rb:270:in `method_mis sing' ./db/migrate//004_hardware.rb:13:in`real\_up’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active\_record/mig  
ration.rb:210:in `migrate' c:/ruby/lib/ruby/1.8/benchmark.rb:293:in`measure’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active\_record/mig  
ration.rb:210:in `migrate' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/mig ration.rb:332:in`migrate’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active\_record/mig  
ration.rb:327:in `migrate' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/mig ration.rb:294:in`up’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active\_record/mig  
ration.rb:285:in `migrate' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/tasks/databases.rake:4 c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in`execute’  
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in`invoke’  
c:/ruby/lib/ruby/1.8/thread.rb:135:in `synchronize' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in`invoke’  
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in`run’  
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7  
c:/ruby/bin/rake.bat:25

This communication is the property of Qwest and may contain confidential  
or  
privileged information. Unauthorized use of this communication is  
strictly  
prohibited and may be unlawful. If you have received this communication  
in error, please immediately notify the sender by reply e-mail and  
destroy  
all copies of the communication and any attachments.

---

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [August 8, 2006, 5:21pm UTC](https://www.ruby-forum.com/t/problem-with-plurals-migrations/101904/2 "2006-08-08T17:21:07Z")

</div>

Hi –

On Tue, 8 Aug 2006, Berger, Daniel wrote:

> def self.up  
> end  
> error:

y – create({:vendor=\>“Foo”, :model=\>“Bar”})

> rake aborted!  
> undefined method `create’ for  
> #ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x39293cc
> 
> My guess is that it was expecting a “hardwares” table instead of  
> “hardware”, and is getting confused. But, I didn’t see a method in the  
> docs to set the table name ala ActiveRecord.

Could the problem be that you’ve got two classes named Hardware?  
Maybe name the migration class CreateHardware and see what happens.

David

–  
[http://www.rubypowerandlight.com](http://www.rubypowerandlight.com) =\> Ruby/Rails training & consultancy  
----\> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! \<-----  
[http://dablog.rubypal.com](http://dablog.rubypal.com) =\> D[avid]A[.]B[lack’s][Web]log  
[Ruby for Rails](http://www.manning.com/black) =\> book, Ruby for Rails  
[http://www.rubycentral.org](http://www.rubycentral.org) =\> Ruby Central, Inc.
