I take a param came of url:
authorization_selected = params[:authorization]
new_parcel = params[:new_parcel].to_i
puts authorization_selected.class (in the console show type String)
puts new_parcel.class (in the console show type Fixnum)
@portability = Portability.new
@portability.employee_id = authorization_selected.employee_id
undefined method `employee_id' for 3:Fixnum
You are calling the
employee_id method on
authorization_selectedwhich is a String and does not provide this method.
Obviously this does not work. You probably want to do
@portability = Portability.new @portability.employee_id = authorization_selected
params[:employee] contains the
Portability is an ActiveModel or an ActiveRecord.
Perhaps you can change your form that the value can be assigned through the initializer?