mysql - Does a Rails foreign_key have to be an integer? -


we have imported data 3rd party provides non-integer unique ids.

in rails 2.2.2 able use :foreign_key on our has_many relationships non-integer column , worked.

but upgrading rails 2.3.8 , seems force foreign_key integer. has found way working?

according this answer, procedure has completed using execute:

create_table :employees, {:id => false} |t|   t.string :emp_id   t.string :first_name   t.string :last_name end execute "alter table employees add primary key (emp_id);" 

and sean mccleary mentioned, activerecord model should set primary key using set_primary_key:

class employee < activerecord::base   set_primary_key :emp_id   ... end 

Comments

Popular posts from this blog

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -

java - Getting corefrences with Standard corenlp package -

jQuery clickable div with working mailto link inside -