Forum: Ruby on Rails making an object id editable?

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.
Hal Robertson (Guest)
on 2006-01-24 09:16
(Received via mailing list)
Hello,

I am a newbie trying to integrate a legacy schema into
a simple Rails app.

The table "sites" has primary key called, "site_key."
The table is in use by other programs written in other
programming languages so I cannot modify the table.

I ran script generate scaffold site and then added:

  set_primary_key "site_key"



to the app/models/site.rb file

The key is a 32 char string that needs to be user
generated

So in app/views/sites/_form.rhtml I added:

<%= text_field 'site', 'site_key'  %>

in the Site Key column, copied from the other fields
in the form.  Looks like it should work but upon
browser reload I get an error, undefined method
`site_key_before_type_cast' for #<Site:0x4081f828>

What does that mean?

Did I make a mistake in my files, or do I need to do
something else to the model to allow for the id to be
editable?

thanks for any help!

Hal







__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
This topic is locked and can not be replied to.