I have been pushing my way through the issues regarding using legacy
database tables and I am making some progress but have run into a
couple of challenges.
The test application I am working with has an employee master file
that has a primary key called "emssan". I have an employee job record
that has a primary key of "shssn". There is one, and only one, job
record for each employee record. I needed to join to the employee
master file to get the name to display on the job record so I built
this relationship:
class Job < ActiveRecord::Base
set_primary_key "shssn"
def self.table_name() "psts301" end
belongs_to :employee, :foreign_key => "shssn"
end
class Employee < ActiveRecord::Base
has_one :job
set_primary_key "emssan"
def self.table_name() "peis301" end
def name
"#{emfnam} #{emlnam}"
end
end
When I display the index, I get a list of employees with names.
Great. When I take the option to show the record, I get a record
returned to view. However, if I take the option to create or edit, I
get an error
Request Failed (code 500, Internal Error)
The log shows the following:
Column EMPLOYEE_ID not in table PSTS301
The question is: Why is Rails looking for a key called EMPLOYEE_ID
when I set the primary key value to "emssan"? How do I fix this?
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---