rails对象期望得到字符串

时间:2016-03-15 19:33:55

标签: ruby-on-rails ruby-on-rails-4 associations

我有这个:

[[1, 1, 6],[1, 2, 5],[1, 7],[2, 6]]

我的控制器:

<%= f.association :gestor, selected: current_usuario.gestor_id, label_method: :descricao, value: current_usuario.gestor_id, disabled: true %>

和控制台:

   def create
    @usuario = Usuario.new(usuario_params)
    respond_to do |format|
      if @usuario.save
        format.html { redirect_to controle_usuarios_path, notice: 'Usuario was successfully updated.' }
        format.json { render :index, status: :ok, location: @usuario }
      else
        format.html { render :new }
      end
    end
  end
(...)
    def usuario_params
          params.require(:usuario).permit(:cpf, :usuario_pai, :gestor_id, :email, :password, :password_confirmation, :agente_id, :perfil_id)
        end

params gestor_id不来,为什么?错误是这样的:

Usuario(#70271925151780)预计,得到字符串(#3432540)

1 个答案:

答案 0 :(得分:1)

Rails正在寻找gester_id,并且您正在传递gester作为参数,因此它将被删除。请尝试将视图更改为gester_id或将参数过滤器更改为gester