I'm very new to RoR, and am trying to test out the scaffolding bit. I
believe there's an issue with my model file and the way I'm using
ActiveRecord, as I'm unable to show specific details of a row. The
table itself displays correctly when I do a 'list' on the webpage, but
a 'show' for a specific row doesn't work. My primary key (id) is not
called 'id', its called 'actor_id'. So, when I try to do a show, or
edit, I get the error :
ActiveRecord::RecordNotFound in Actor#show
Couldn't find Actor without an ID
How can I map my table column's primary key id (called 'actor_id') to
'id' in the model file? I've tried using 'id=actor_id', primary_key,
etc. in my model file (actor.rb) but nothing seems to work seemlessly,
unless I modify the stubs that're created when I run the ruby
script\generate scaffold.
Here's what I did to set things up :
1. I have a database called 'test', inside of which I have one table
'actors' (I don't know, just felt very hollywood-ish today). The
columns in the table are:
Actor_id (primary key)
Actor_fname
Actor_lname
Actor_address
2. modify database.yml to point to the right database, host, table etc.
3. ruby script\generate model actor
4. ruby script\generate controller actor
5. add 'scaffold:actor' to actor_controller.rb
6. ruby script\server
7. http://localhost:3000/actor
8. error occurs when I click on the 'show' link for one of the columns
: ActiveRecord::RecordNotFound in Actor#show Couldn't find Actor
without an ID
I appreciate any help you can offer. Thanks in advance,
BYT