problem with composite keys with strings

91 views
Skip to first unread message

Eduardo Puente

unread,
Mar 7, 2014, 1:16:38 PM3/7/14
to compos...@googlegroups.com
I have a table with two fields for the primary key, both are string the models are empleado and email; The creation of a new record works ok, but when I try to edit the record, I got the error "undefined method `numempleado_before_type_cast' for #<Email:0xbcc32a0>

Im using nested attributes in the form


require 'composite_primary_keys'
class Email < ActiveRecord::Base
    self.primary_keys = [:numempleado, :email]


    belongs_to :empleado, :class_name => 'Empleado', :foreign_key => :empleado_id    
end




class Empleado < ActiveRecord::Base
    self.primary_key = :numempleado

    has_many :cuentas, :class_name => 'Cuenta'    
    has_many :emails, :class_name => 'Email'    
    has_many :horarios, :class_name => 'Horario'    
    has_many :operadorsala, :class_name => 'Operadorsala'    
    has_many :productorasignado, :class_name => 'Productorasignado'    
    has_many :productorsolicitado, :class_name => 'Productorsolicitado' 
    belongs_to :tipoempleado, :class_name => 'Tipoempleado', :foreign_key => :tipoempleado_id     


    accepts_nested_attributes_for :horarios, allow_destroy: true, reject_if: lambda {|attributes| attributes['horainicio'].blank?}
    accepts_nested_attributes_for :cuentas, allow_destroy: true 
    accepts_nested_attributes_for :emails, allow_destroy: true, reject_if: lambda {|attributes| attributes['email'].blank?}
end

cfis

unread,
May 27, 2014, 2:22:52 AM5/27/14
to compos...@googlegroups.com
Hi Eduardo,

Please move this over to Github.  Also, whate version of ActiveRecord and CPK?

Charlie
Reply all
Reply to author
Forward
0 new messages