ActionController::ParameterMissing param is missing or the value is empty

安稳与你 提交于 2019-12-04 19:52:54

You should call Message.new without params because message_params nil in this request and this raise ActionController::ParameterMissing:

class ChatroomsController < ApplicationController      
   #.........
   def new
      @user = User.find(params[:user_id])
      @cart = Cart.find(params[:user_id])
      @item = Item.find(params[:item_id])
      @message = Message.new
   end

   #........

   private

   def message_params
      params.require(:messages).permit(:id,:user_id,:messages)
   end
   #.......
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!