允许的未知属性'utf8'

时间:2017-11-27 08:21:49

标签: ruby-on-rails utf-8 activeadmin

我在ActiveAdmin控制器内部工作。我正在尝试传递allowed_pa​​rams以及当前日期和当前登录的用户。但是,每当我提交时,我都会收到Unknown attribute 'utf8' for Permit错误。

系统管理员/ permit.rb

form do |f|
    f.inputs do
        f.input :vehicle, :collection => Vehicle.all.map{ |vehicle| [vehicle.license_number]}
        f.input :permit_id
        f.input :date_issued, as: :date_picker
        f.input :issued_by
    end
    f.actions
end

controller do
    def new
        @permit = Permit.new
        @vehicle = @permit.build_vehicle 
    end 

    def create
         #@permit = Permit.new
         vehicle = Vehicle.find_by(permitted_params[:vehicle])
         @permit = current_user.permit.build(permitted_params.merge(date_entered: Date.today, 
            entered_by: current_admin_user.email))
         @permit.update(vehicle: vehicle)
         super
    end

    def permittted_params
        params.require(:permit).permit(:permit_id, :date_issued, :issued_by, :date_entered, :entered_by, vehicle_attributes: [:license_number])
    end

    def set_permit
        @permit = Permit.find(params[:id])
    end
end

有人知道我为什么会收到这个错误吗?我在正常的rails应用程序中没有收到此错误,并且它运行的代码几乎相同。感谢

修改

这是应用程序跟踪

app/admin/permit.rb:61:in `create'
Request

Parameters:

{"utf8"=>"✓","authenticity_token"=>"zw3Px+gEOvp2UDufgiBNyG0yShTHQYBIsOK+WWj7wiYkMNkR3aLku5TMBxK5b0mQoZvKr+w6YgYZVPGxURtH0A==",
 "permit"=>{"permit_id"=>"ST-5555", "date_issued"=>"2018-11-24", 
"issued_by"=>"Nate"},
 "commit"=>"Create Permit"}

1 个答案:

答案 0 :(得分:0)

当我使用邮递员时,我遇到了这个错误。 设置标题:enctype multipart/form-data; charset=utf-8