# Newbie:Adding a new Table-Strange Error

**URL:** <https://www.ruby-forum.com/t/newbie-adding-a-new-table-strange-error/98003>\
**Category:** Rails\
**Created:** [January 27, 2006, 7:07pm UTC](https://www.ruby-forum.com/t/newbie-adding-a-new-table-strange-error/98003 "2006-01-27T19:07:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![deniz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@deniz](https://www.ruby-forum.com/u/deniz)\
**Post date:** [January 27, 2006, 7:07pm UTC](https://www.ruby-forum.com/t/newbie-adding-a-new-table-strange-error/98003/1 "2006-01-27T19:07:12Z")

</div>

Hi Everybody,  
I am a newbie in this list so please forgive me if this is a lengthy  
message.  
Currently I am working on a project at my work place that includes  
viewing some oracle tables(I do not have control over to rewrite the  
tables) and searching the tables based on a given criteria with Rails.  
Up untill now everything was working great. The database consists of a  
lot of tables but I was working with five of them. Then I realized that  
one of the fields in a table was referring to another table in the  
database. For example if I had a DN (Directory Number) in the table,  
that three digit DN was referring to another table being an actual DN.  
So I decided to add that table. The actual name of the table is cfg\_dn  
(Legacy) with the following assignments I created the model/controller  
and view

\*/ruby script/generate scaffold cfg\_dn cfg\_dn

/\*Again, up untill now everything that I wanted to do with the database  
was working properly. I went ahead and typed the following to my browser  
to see if I am hitting the table.

/\*[http://localhost:3000/cfg\_dn\*/](http://localhost:3000/cfg_dn*/)

To my amazement the error I got:

NoMethodError in Cfg\_dn#index

undefined method `empty?’ for 3:Fixnum

|RAILS\_ROOT: ./script/…/config/…|

Application Trace [http://localhost:3000/cfg\_dn#](http://localhost:3000/cfg_dn#) | Framework Trace  
[http://localhost:3000/cfg\_dn#](http://localhost:3000/cfg_dn#) | Full Trace  
[http://localhost:3000/cfg\_dn#](http://localhost:3000/cfg_dn#)

|c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active\_record/base.rb:890:in `instantiate_without_callbacks' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:215:in `instantiate’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active\_record/base.rb:431:in  
`find_by_sql' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `collect!’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active\_record/base.rb:431:in  
`find_by_sql' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:395:in `find’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/pagination.rb:174:in  
`find_collection_for_pagination' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:192:in `paginator\_and\_collection\_for’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/pagination.rb:124:in  
`paginate' #{RAILS_ROOT}/app/controllers/cfg_dn_controller.rb:8:in `list’  
#{RAILS\_ROOT}/app/controllers/cfg\_dn\_controller.rb:3:in `index’|

|c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active\_record/base.rb:890:in `instantiate_without_callbacks' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:215:in `instantiate’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active\_record/base.rb:431:in  
`find_by_sql' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `collect!’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active\_record/base.rb:431:in  
`find_by_sql' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:395:in `find’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/pagination.rb:174:in  
`find_collection_for_pagination' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:192:in `paginator\_and\_collection\_for’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/pagination.rb:124:in  
`paginate' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in `send’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/base.rb:853:in  
`perform_action_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in `perform\_action\_without\_benchmark’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/benchmarking.rb:69:in  
`perform_action_without_rescue' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `measure’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/benchmarking.rb:69:in  
`perform_action_without_rescue' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in `perform\_action’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/base.rb:369:in  
`send' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in `process\_without\_session\_management\_support’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/session\_management.rb:116:in  
`process' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in `dispatch’  
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick\_server.rb:117:in  
`handle_dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in `service’  
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run’  
c:/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start’  
c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start’  
c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each' c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start’  
c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start' c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start’  
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick\_server.rb:69:in  
`dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require\_\_’  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:18:in  
`require' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require’  
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:18:in  
`require__' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require’  
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active\_support/dependencies.rb:214:in  
`require’  
script/server:5|

|c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active\_record/base.rb:890:in `instantiate_without_callbacks' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:215:in `instantiate’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active\_record/base.rb:431:in  
`find_by_sql' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:431:in `collect!’  
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active\_record/base.rb:431:in  
`find_by_sql' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:395:in `find’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/pagination.rb:174:in  
`find_collection_for_pagination' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:192:in `paginator\_and\_collection\_for’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/pagination.rb:124:in  
`paginate' #{RAILS_ROOT}/app/controllers/cfg_dn_controller.rb:8:in `list’  
#{RAILS\_ROOT}/app/controllers/cfg\_dn\_controller.rb:3:in `index' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in `send’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/base.rb:853:in  
`perform_action_without_filters' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in `perform\_action\_without\_benchmark’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/benchmarking.rb:69:in  
`perform_action_without_rescue' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `measure’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/benchmarking.rb:69:in  
`perform_action_without_rescue' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in `perform\_action’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/base.rb:369:in  
`send' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in `process\_without\_session\_management\_support’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/session\_management.rb:116:in  
`process' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in `dispatch’  
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick\_server.rb:117:in  
`handle_dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in `service’  
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run’  
c:/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start’  
c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start’  
c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each' c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start’  
c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start' c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start’  
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick\_server.rb:69:in  
`dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require\_\_’  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:18:in  
`require' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require’  
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28  
c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:18:in  
`require__' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require’  
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active\_support/dependencies.rb:214:in  
`require’  
script/server:5|

```
Request

```

_Parameters_: None

Show session dump [http://localhost:3000/cfg\_dn#](http://localhost:3000/cfg_dn#)

* * *

flash: !ruby/hash:ActionController::Flash::FlashHash {}

```
Response

```

_Headers_: {“cookie”=\>[], “Cache-Control”=\>“no-cache”}

Also please note that when i do the same thing for the previous five  
tables, it works. It is just this table that I am having problem with.  
And another thing is that I am able to see this table using Brio  
Software (This software allows you to put together tables and do some  
queries on it). So the table is definetely there and the contents are  
definetely there.  
I do not know what this error means and I do not know how to fix it.  
Could any one give me some suggestions?  
I would be more than happy to give more information if necessary.  
Thanks a lot  
Deniz Rende.

---

<div class="post-metadata">

**Author:** ![deniz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@deniz](https://www.ruby-forum.com/u/deniz)\
**Post date:** [January 28, 2006, 11:06am UTC](https://www.ruby-forum.com/t/newbie-adding-a-new-table-strange-error/98003/2 "2006-01-28T11:06:51Z")

</div>

Deniz wrote:

> table, that three digit DN was referring to another table being an  
> /\*[http://localhost:3000/cfg\_dn\*/](http://localhost:3000/cfg_dn*/)  
> Application Trace [http://localhost:3000/cfg\_dn#](http://localhost:3000/cfg_dn#) | Framework Trace  
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/pagination.rb:192:in `paginator_and_collection_for' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:174:in `find\_collection\_for\_pagination’  
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/base.rb:369:in `process_without_session_management_support' c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each’  
> c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:18:in `require' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:192:in `paginator\_and\_collection\_for’  
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action\_controller/base.rb:369:in `send' c:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start’  
> c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:18:in `require\_\_’
> 
> And another thing is that I am able to see this table using Brio
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Could anybody help me with this problem please? I am seriously  
frustrated that I could not figure out what’s going on with this.  
Thanx in advace  
Deniz…

---

<div class="post-metadata">

**Author:** ![deniz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@deniz](https://www.ruby-forum.com/u/deniz)\
**Post date:** [January 28, 2006, 12:20pm UTC](https://www.ruby-forum.com/t/newbie-adding-a-new-table-strange-error/98003/3 "2006-01-28T12:20:41Z")

</div>

You call a method empty? on a number. Numbers don’t have this method:

4.empty? =\> ERROR!

Arrays do:

[1, 2, 3].empty? =\> false  
[].empty? =\> true

Note that the number may also be in a variable:

num = 5  
num.empty?

Jules

---

<div class="post-metadata">

**Author:** ![deniz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@deniz](https://www.ruby-forum.com/u/deniz)\
**Post date:** [January 28, 2006, 11:46pm UTC](https://www.ruby-forum.com/t/newbie-adding-a-new-table-strange-error/98003/4 "2006-01-28T23:46:00Z")

</div>

Ben M. wrote:

> Usage: script/generate scaffold ModelName [ControllerName] [action, …]
> 
> Hope this helps,
> 
> b
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Yes, you see I started out naming the table name as you suggested. As a  
matter of fact, the other tables are named like this too. For example  
the table names are gcdr, scdr, evref, evrefex, and arec. I had to use  
“set\_table\_name …” for each of them to override.I googled this error  
but could not come up with anything…  
Thanx…

---

<div class="post-metadata">

**Author:** ![deniz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@deniz](https://www.ruby-forum.com/u/deniz)\
**Post date:** [January 28, 2006, 11:52pm UTC](https://www.ruby-forum.com/t/newbie-adding-a-new-table-strange-error/98003/5 "2006-01-28T23:52:02Z")

</div>

Jules J. wrote:

> num = 5  
> num.empty?
> 
> Jules

No actually I did not, when I created the model/controller and viewer it  
came up like that. That is the “weirdness” of the error.  
I am just adding a new table to the application in the same way I did  
for the other ones…  
Any suggestions?

---

<div class="post-metadata">

**Author:** ![deniz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@deniz](https://www.ruby-forum.com/u/deniz)\
**Post date:** [January 28, 2006, 6:45pm UTC](https://www.ruby-forum.com/t/newbie-adding-a-new-table-strange-error/98003/6 "2006-01-28T18:45:26Z")

</div>

Deniz wrote:

> Deniz wrote:
> 
> > \*/ruby script/generate scaffold cfg\_dn cfg\_dn

I’m still pretty new too, but this looked weird… Scaffold help says:

> ruby script\generate scaffold  
> Usage: script/generate scaffold ModelName [ControllerName] [action, …]

So, I don’t think you want “cfg\_dn”. The first arg after scaffold should  
be your model  
name in camel case. Then, the controller, _if_ you need it to have a  
different name.

Ruby best practices also discourage abbreviations for class names, so I  
wouldn’t call your  
model CfgDn. I imagine you’re using that because that’s a table name. I  
think in this case  
you’ll need to override the default naming and tell the model what table  
you’re using with  
“set\_table\_name cfg\_dn”.

Hope this helps,

b
