[英]param is missing or the value is empty: user
我正在使用Postman來測試我的API並且我得到錯誤param is missing or the value is empty: user
在調用http://localhost:3000/users.json
來創建新用戶時。 所有參數似乎都沒問題。
我在應用程序控制器中設置了它:
protect_from_forgery with: :null_session
我的控制器方法是基本的腳手架生成方法:
def create
@user = User.new(user_params)
respond_to do |format|
if @user.save
format.html { redirect_to @user, notice: 'User was successfully created.' }
format.json { render :show, status: :created, location: @user }
else
format.html { render :new }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
我究竟做錯了什么?
編輯:
這是我在Postman中所做的截圖。
問題是我的參數沒有被包裝成user
對象。 例如,在我的情況下,我將不得不更改參數:
username
對於:
user[username]
為所有參數執行此操作使測試工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.