用于“写入flash消息”的未定义方法`keys':string

时间:2017-02-10 05:59:07

标签: ruby-on-rails ruby redirect

你好我得到这个错误不知道如何去做,因为这是第一次体验。

  • “您已提交完成的写作文档”的未定义方法“键”:字符串

我正在更新数据库行,然后在成功后重定向,并在redirect_to your_reservations_path, flash: "You have submitted your Completed Writing Document"

上突出显示错误

我的控制器预约:

def update
  if @reservation.update(reservation_params)
    puts 'first'
    if reservation_params.has_key?(:completed_doc)
      puts 'second'
      @reservation.update_attributes turned_in: true
      redirect_to your_reservations_path, flash: "You have submitted your Completed Writing Document"
    else

      redirect_to your_reservations_path, alert: "Oops, something went wrong..."
    end
  else
    render '_edit'
  end
end

1 个答案:

答案 0 :(得分:2)

尝试将其更改为:notice

redirect_to your_reservations_path, 
            notice: "You have submitted your Completed Writing Document"