Forum: Ruby on Rails Couldn't find Type without an ID

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Gangadhar M. (Guest)
on 2007-07-30 02:55
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"}
Adam G. (Guest)
on 2007-07-30 03:12
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
Gangadhar M. (Guest)
on 2007-07-30 08:08
Attachment: ruby-on-rails-error.png (0 Bytes)
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 "<td><%= link_to 'Show', :action => 'show',
:id => id %></td>" in list.rhtml to "<td><%= link_to 'Show', :action =>
'show', :id => item_type.item_type_id %></td>", 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
Gangadhar M. (Guest)
on 2007-07-30 08:09
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 "<td><%= link_to 'Show', :action => 'show',
> :id => id %></td>" in list.rhtml to "<td><%= link_to 'Show', :action =>
> 'show', :id => item_type.item_type_id %></td>", 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
Kip (Guest)
on 2007-07-30 09:27
(Received via mailing list)
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-
Kip (Guest)
on 2007-07-30 09:31
(Received via mailing list)
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-
Adam G. (Guest)
on 2007-07-30 11:16
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
JN_Coward (Guest)
on 2007-07-30 13:48
(Received via mailing list)
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-
This topic is locked and can not be replied to.