I have a parameter (params[:authorization]) that comes from the URL, as you can see:
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)
In my controller, have:
@portability = Portability.new
@portability.employee_id = authorization_selected.employee_id
However this returns an error:
undefined method `employee_id' for 3:Fixnum
I need that both was integer. How do it?
You are calling the
employee_idmethod onauthorization_selectedwhich is a String and does not provide this method. Obviously this does not work. You probably want to doassuming that
params[:employee]contains theemployee_idandPortabilityis an ActiveModel or an ActiveRecord.Perhaps you can change your form that the value can be assigned through the initializer?