# Couldn't find Type without an ID

**URL:** <https://www.ruby-forum.com/t/couldnt-find-type-without-an-id/110706>\
**Category:** Rails\
**Created:** [July 30, 2007, 12:55am UTC](https://www.ruby-forum.com/t/couldnt-find-type-without-an-id/110706 "2007-07-30T00:55:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fgdhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ac8455/32.png) [@fgdhar](https://www.ruby-forum.com/u/fgdhar)\
**Post date:** [July 30, 2007, 12:55am UTC](https://www.ruby-forum.com/t/couldnt-find-type-without-an-id/110706/1 "2007-07-30T00:55:50Z")

</div>

Hi,  
I am trying to learn Ruby on Rails programming. I have installed  
“Instant Rails” and trying to build a small application. I created a  
table called “types” for the application.  
Below is the structure of the types database table.  
±---------------±----------------±-----±----±--------±---------------+  
| Field | Type | Null | Key | Default | Extra |  
±---------------±----------------±-----±----±--------±---------------+  
| item\_type\_id | int(4) unsigned | NO | PRI | NULL | auto\_increment |  
| item\_type | varchar(3) | YES | | NULL | |  
| item\_type\_desc | varchar(50) | YES | | NULL | |  
| created\_by | varchar(30) | YES | | NULL | |  
| created\_on | date | YES | | NULL | |  
| modified\_by | varchar(30) | YES | | NULL | |  
| modified\_date | date | YES | | NULL | |  
±---------------±----------------±-----±----±--------±---------------+

I tried to build a rails application using the articles “Rolling with  
Ruby on Rails” and “Rolling with Ruby on Rails, Part 2”. I build an  
application called “mylibrary” using command “rails mylbirary”. Made  
necessary changes in database.yml file under config folder to connect to  
the database. Used another command “ruby script\generate scaffold type”  
to create both model and controller related classes.  
I tried to run the newly created application in browser. The URLs  
“http:\localhost:3000\type\new” and “http:\localhost:3000\type\list”  
are working. But when I tried to access  
"“http:\localhost:3000\type\show”, which displays details of a  
particular type, it is throwing below error details.

I thought the application should be working with out making any changes.  
If I need to make any changes, I could not find proper documentation on  
where and how I should make these changes. I would appreciate if  
someone can help me in understanding this and moving further with my  
development.

==== Error log ====  
ActiveRecord::RecordNotFound in TypesController#show

Couldn’t find Type without an ID

RAILS\_ROOT: C:/SOFTWA~1/INSTAN~1/rails\_apps/mylibrary/config/…  
Application Trace | Framework Trace | Full Trace

C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:1012:in  
`find_from_ids' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:419:in`find’  
#{RAILS\_ROOT}/app/controllers/types\_controller.rb:16:in `show’

C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:1012:in  
`find_from_ids' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:419:in`find’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:1095:in  
`send' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in`perform\_action\_without\_filters’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/filters.rb:632:in  
`call_filter' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:634:in`call\_filter’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/filters.rb:619:in  
`perform_action_without_benchmark' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in`perform\_action\_without\_rescue’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in`perform\_action\_without\_rescue’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/rescue.rb:83:in  
`perform_action' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in`send’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:430:in  
`process_without_filters' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in`process\_without\_session\_management\_support’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/session\_management.rb:114:in  
`process' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in`process’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in  
`dispatch' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:78:in`process’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in  
`synchronize' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in`process’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:618:in  
`process_client' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in`each’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in  
`process_client' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`initialize' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`new’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in`initialize’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in  
`new' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:271:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in`each’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails:127:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/command.rb:211:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails:243 C:/SOFTWA~1/INSTAN~1/ruby/bin/mongrel_rails:16:in`load’  
C:/SOFTWA~1/INSTAN~1/ruby/bin/mongrel\_rails:16

C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:1012:in  
`find_from_ids' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:419:in`find’  
#{RAILS\_ROOT}/app/controllers/types\_controller.rb:16:in `show' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in`send’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:1095:in  
`perform_action_without_filters' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:632:in`call\_filter’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/filters.rb:634:in  
`call_filter' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:619:in`perform\_action\_without\_benchmark’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:in`measure’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/rescue.rb:83:in`perform\_action’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:430:in  
`send' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in`process\_without\_filters’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/filters.rb:624:in  
`process_without_session_management_support' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in`process’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:330:in  
`process' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in`dispatch’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:78:in  
`process' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in`synchronize’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in  
`process' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:618:in`process\_client’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in  
`each' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in`process\_client’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`initialize’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`new' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in  
`initialize' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in`new’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:271:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in  
`each' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel\_rails:127:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/command.rb:211:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel\_rails:243  
C:/SOFTWA~1/INSTAN~1/ruby/bin/mongrel\_rails:16:in `load’  
C:/SOFTWA~1/INSTAN~1/ruby/bin/mongrel\_rails:16

Request

Parameters: None

Show session dump

* * *

flash: !map:ActionController::Flash::FlashHash {}

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

---

<div class="post-metadata">

**Author:** ![fgdhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ac8455/32.png) [@fgdhar](https://www.ruby-forum.com/u/fgdhar)\
**Post date:** [July 30, 2007, 1:12am UTC](https://www.ruby-forum.com/t/couldnt-find-type-without-an-id/110706/2 "2007-07-30T01:12:33Z")

</div>

Gangadhar Moganti wrote:

> I tried to run the newly created application in browser. The URLs  
> “http:\localhost:3000\type\new” and “http:\localhost:3000\type\list”  
> are working. But when I tried to access  
> "“http:\localhost:3000\type\show”, which displays details of a  
> particular type, it is throwing below error details.

It looks to me like your request is not specifying the id of the type  
you wish to show the details for. Instead of  
“http:\localhost:3000\type\show”, try using  
“http:\localhost:3000\type\show\1”. The general pattern you need to use  
when working with a single object is  
“http:\localhost:3000\<controller\>\<action\>\<id\>”.

> I created a table called “types” for the application.

I would also advise against the use of the word ‘type’ for a model  
class; while not a reserved word, it is a word with special meaning -  
when used on an object, it returns the class of that object (although  
this use is deprecated), and type is also used by Rails as a special  
column/attribute to identify the sub-type of an object when using  
single-table inheritance.

Hope this helps,

Adam

---

<div class="post-metadata">

**Author:** ![fgdhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ac8455/32.png) [@fgdhar](https://www.ruby-forum.com/u/fgdhar)\
**Post date:** [July 30, 2007, 6:08am UTC](https://www.ruby-forum.com/t/couldnt-find-type-without-an-id/110706/3 "2007-07-30T06:08:20Z")

</div>

Adam G. wrote:

> Gangadhar Moganti wrote:
> 
> > I tried to run the newly created application in browser. The URLs  
> > “http:\localhost:3000\type\new” and “http:\localhost:3000\type\list”  
> > are working. But when I tried to access  
> > "“http:\localhost:3000\type\show”, which displays details of a  
> > particular type, it is throwing below error details.
> 
> It looks to me like your request is not specifying the id of the type  
> you wish to show the details for. Instead of  
> “http:\localhost:3000\type\show”, try using  
> “http:\localhost:3000\type\show\1”. The general pattern you need to use  
> when working with a single object is  
> “http:\localhost:3000\<controller\>\<action\>\<id\>”.
> 
> > I created a table called “types” for the application.
> 
> I would also advise against the use of the word ‘type’ for a model  
> class; while not a reserved word, it is a word with special meaning -  
> when used on an object, it returns the class of that object (although  
> this use is deprecated), and type is also used by Rails as a special  
> column/attribute to identify the sub-type of an object when using  
> single-table inheritance.
> 
> Hope this helps,
> 
> Adam

Hi Adam,  
Thanks for your help. I changed the name of table to “item\_types”  
and changed the statement “

\<%= link\_to ‘Show’, :action =\> ‘show’,  
:id =\> id %\>” in list.rhtml to “\<%= link\_to ‘Show’, :action =\>  
‘show’, :id =\> item\_type.item\_type\_id %\>”, as the original  
statement was resulting in forming the URL  
“http:\localhost:3000\type\show”. After making the change the  
resultant URL returned is “http:\localhost:3000\type\show\1”. But  
still I am getting errors. This time the first sentence in the error  
log is “Mysql::Error: Unknown column ‘item\_types.id’ in ‘where clause’:  
SELECT \* FROM item\_types WHERE (item\_types.`id` = ‘1’)”. I am not sure  
why I am getting this error and whether the change I made was correct or  
not. I would appreciate if you can provide me any more guidance on  
this. Attached is the complete error log. I appreciate your help in  
resolving this

---

<div class="post-metadata">

**Author:** ![fgdhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ac8455/32.png) [@fgdhar](https://www.ruby-forum.com/u/fgdhar)\
**Post date:** [July 30, 2007, 7:27am UTC](https://www.ruby-forum.com/t/couldnt-find-type-without-an-id/110706/4 "2007-07-30T07:27:47Z")

</div>

Gangadhar,

It looks like you don’t have an “id” - not “item\_type\_id” - just plain  
old “id” column. Rails works best if tables have “id” as their.  
primary key.

It’s recommended you use migrations to build and mange your database  
tables - this will automatically create the “id” column for you  
(amongst other things).

I think if you change the name of your primary key column to “id”  
however I think you’ll move forward…

Cheers, --Kip

On Jul 30, 6:55 am, Gangadhar Moganti \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![fgdhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ac8455/32.png) [@fgdhar](https://www.ruby-forum.com/u/fgdhar)\
**Post date:** [July 30, 2007, 6:09am UTC](https://www.ruby-forum.com/t/couldnt-find-type-without-an-id/110706/5 "2007-07-30T06:09:33Z")

</div>

Gangadhar Moganti wrote:

> Adam G. wrote:
> 
> > Gangadhar Moganti wrote:
> > 
> > > I tried to run the newly created application in browser. The URLs  
> > > “http:\localhost:3000\type\new” and “http:\localhost:3000\type\list”  
> > > are working. But when I tried to access  
> > > "“http:\localhost:3000\type\show”, which displays details of a  
> > > particular type, it is throwing below error details.
> > 
> > It looks to me like your request is not specifying the id of the type  
> > you wish to show the details for. Instead of  
> > “http:\localhost:3000\type\show”, try using  
> > “http:\localhost:3000\type\show\1”. The general pattern you need to use  
> > when working with a single object is  
> > “http:\localhost:3000\<controller\>\<action\>\<id\>”.
> > 
> > > I created a table called “types” for the application.
> > 
> > I would also advise against the use of the word ‘type’ for a model  
> > class; while not a reserved word, it is a word with special meaning -  
> > when used on an object, it returns the class of that object (although  
> > this use is deprecated), and type is also used by Rails as a special  
> > column/attribute to identify the sub-type of an object when using  
> > single-table inheritance.
> > 
> > Hope this helps,
> > 
> > Adam
> 
> Hi Adam,  
> Thanks for your help. I changed the name of table to “item\_types”  
> and changed the statement “
> 
> \<%= link\_to ‘Show’, :action =\> ‘show’,  
> :id =\> id %\>” in list.rhtml to “\<%= link\_to ‘Show’, :action =\>  
> ‘show’, :id =\> item\_type.item\_type\_id %\>”, as the original  
> statement was resulting in forming the URL  
> “http:\localhost:3000\type\show”. After making the change the  
> resultant URL returned is “http:\localhost:3000\type\show\1”. But  
> still I am getting errors. This time the first sentence in the error  
> log is “Mysql::Error: Unknown column ‘item\_types.id’ in ‘where clause’:  
> SELECT \* FROM item\_types WHERE (item\_types.`id` = ‘1’)”. I am not sure  
> why I am getting this error and whether the change I made was correct or  
> not. I would appreciate if you can provide me any more guidance on  
> this. Attached is the complete error log. I appreciate your help in  
> resolving this

Sorry, I forgot to add the error log. Here it is.  
ActiveRecord::StatementInvalid in Item typesController#show

Mysql::Error: Unknown column ‘item\_types.id’ in ‘where clause’: SELECT \*  
FROM item\_types WHERE (item\_types.`id` = ‘1’)

RAILS\_ROOT: C:/SOFTWA~1/INSTAN~1/rails\_apps/mylibrary/config/…  
Application Trace | Framework Trace | Full Trace

C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/connection\_adapters/abstract\_adapter.rb:128:in  
`log' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:243:in`execute’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/connection\_adapters/mysql\_adapter.rb:399:in  
`select' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in`select\_all’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:427:in  
`find_by_sql' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:997:in`find\_every’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:1028:in  
`find_one' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1014:in`find\_from\_ids’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:419:in  
`find' #{RAILS_ROOT}/app/controllers/item_types_controller.rb:16:in`show’

C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/connection\_adapters/abstract\_adapter.rb:128:in  
`log' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:243:in`execute’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/connection\_adapters/mysql\_adapter.rb:399:in  
`select' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in`select\_all’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:427:in  
`find_by_sql' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:997:in`find\_every’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:1028:in  
`find_one' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1014:in`find\_from\_ids’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:419:in  
`find' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in`send’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:1095:in  
`perform_action_without_filters' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:632:in`call\_filter’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/filters.rb:634:in  
`call_filter' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:619:in`perform\_action\_without\_benchmark’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:in`measure’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/rescue.rb:83:in`perform\_action’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:430:in  
`send' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in`process\_without\_filters’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/filters.rb:624:in  
`process_without_session_management_support' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in`process’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:330:in  
`process' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in`dispatch’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:78:in  
`process' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in`synchronize’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in  
`process' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:618:in`process\_client’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in  
`each' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in`process\_client’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`initialize’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`new' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in  
`initialize' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in`new’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:271:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in  
`each' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel\_rails:127:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/command.rb:211:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel\_rails:243  
C:/SOFTWA~1/INSTAN~1/ruby/bin/mongrel\_rails:16:in `load’  
C:/SOFTWA~1/INSTAN~1/ruby/bin/mongrel\_rails:16

C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/connection\_adapters/abstract\_adapter.rb:128:in  
`log' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:243:in`execute’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/connection\_adapters/mysql\_adapter.rb:399:in  
`select' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in`select\_all’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:427:in  
`find_by_sql' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:997:in`find\_every’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:1028:in  
`find_one' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1014:in`find\_from\_ids’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:419:in  
`find' #{RAILS_ROOT}/app/controllers/item_types_controller.rb:16:in`show’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:1095:in  
`send' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in`perform\_action\_without\_filters’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/filters.rb:632:in  
`call_filter' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:634:in`call\_filter’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/filters.rb:619:in  
`perform_action_without_benchmark' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in`perform\_action\_without\_rescue’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in`perform\_action\_without\_rescue’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/rescue.rb:83:in  
`perform_action' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in`send’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/base.rb:430:in  
`process_without_filters' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in`process\_without\_session\_management\_support’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/session\_management.rb:114:in  
`process' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in`process’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in  
`dispatch' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:78:in`process’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in  
`synchronize' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/rails.rb:76:in`process’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:618:in  
`process_client' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in`each’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:617:in  
`process_client' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`initialize' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in`new’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:736:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in`initialize’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in  
`new' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel.rb:720:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:271:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in`each’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/configurator.rb:270:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails:127:in`run’  
C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/mongrel/command.rb:211:in  
`run' C:/SOFTWA~1/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/mongrel_rails:243 C:/SOFTWA~1/INSTAN~1/ruby/bin/mongrel_rails:16:in`load’  
C:/SOFTWA~1/INSTAN~1/ruby/bin/mongrel\_rails:16

Request

Parameters: {“id”=\>“1”}

Show session dump

* * *

flash: !map:ActionController::Flash::FlashHash {}

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

-Gangadhar

---

<div class="post-metadata">

**Author:** ![fgdhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ac8455/32.png) [@fgdhar](https://www.ruby-forum.com/u/fgdhar)\
**Post date:** [July 30, 2007, 7:31am UTC](https://www.ruby-forum.com/t/couldnt-find-type-without-an-id/110706/6 "2007-07-30T07:31:47Z")

</div>

Also looking further at your model,I suggest you make some other  
modifications:

if you have the columns “created\_at” and “updated\_at” then Rails will  
automitically update them with the relevant datetime (or created\_on/  
updated\_on for date columns). So I suggest you change your  
modified\_date and created\_on column names.

Rails is a world where following convention gets you great  
productivity gains, and not following convention can cause pain and  
anguish - as I am learning very fast.

Cheers, --Kip

On Jul 30, 6:55 am, Gangadhar Moganti \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![fgdhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ac8455/32.png) [@fgdhar](https://www.ruby-forum.com/u/fgdhar)\
**Post date:** [July 30, 2007, 9:16am UTC](https://www.ruby-forum.com/t/couldnt-find-type-without-an-id/110706/7 "2007-07-30T09:16:03Z")

</div>

Kip wrote:

> I think if you change the name of your primary key column to “id”  
> however I think you’ll move forward…

As Kip says, following conventions such as using a primary key field of  
‘id’ and naming your model after your database table (e.g. class  
ItemType for table ITEM\_TYPES) is the path of least resistance…

However, sometimes the conventions don’t suit. In these cases, Rails  
usually provides a way of overriding the convention. So instead of  
renaming your item\_types\_id field to id, you could add the following  
line to the top of your model file:

set\_primary\_key ‘item\_type\_id’

Cheers,

Adam

---

<div class="post-metadata">

**Author:** ![fgdhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ac8455/32.png) [@fgdhar](https://www.ruby-forum.com/u/fgdhar)\
**Post date:** [July 30, 2007, 11:48am UTC](https://www.ruby-forum.com/t/couldnt-find-type-without-an-id/110706/8 "2007-07-30T11:48:17Z")

</div>

Hi,

as the others quite rightly pointed out you shouldn’t use type as a  
model name in Rails. However, I suspect the error you got wasn’t  
caused by this, but rather by the fact that you were trying to access:

/type/show

instead of say:

/type/show/5

if you look at your controller it will look something like:

def show  
@type = Type.find(params[:id])  
end

params[:id] in your case will be nil (after all you did not specify  
one, right?) so it will basically try to do Type.find(nil) if you fire  
up the console, you’ll see that this doesn’t work.

This is an inelegance of how actions map to controllers, and once you  
get better and start using map.resources this inelegance will be gone.  
Just hang in there.

Also I really recommend you put down the Rolling with Rails article  
and go out and buy the Agile Web D. With Rails (Second  
Edition!) book. I remember that Rolling with Rails was the first  
article about Rails I read. The interesting part is that at the time,  
it was pretty much the ONLY article about Rails. Yes, this was almost  
two years ago. So buy the book and save yourself some pain.

/Jonas

On 30 Juli, 07:55, Gangadhar Moganti \<rails-mailing-l…@andreas-
