は、しばらくの間、合格RSPECとその慣れていないために、このいずれかを取得しようとすると失敗し、カップルの答えを試みたが、まだ運が、私は次のように私のコントローラ上で必要とされているこれら2つのパラメータを持っていない:RSpecのテストが強いのparams
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
redirect_back fallback_location: new_user_path
else
render :new
end
end
private
def user_params
params.require(:user).permit(:username, :password)
end
end
、これは私に問題を与えているRSpecのテストである:ここ
describe "GET #create" do
it "returns http success" do
get :create
expect(response).to have_http_status(:success)
end
end
は、私が取得していますエラーです:
1) UsersController GET #create returns http success
Failure/Error: params.require(:user).permit(:username, :password)
ActionController::ParameterMissing:
param is missing or the value is empty: user
私は今rspecのドキュメントを見ていますが、どんな助けにも感謝します。
あなたのparamsは、' {形式でなければなりません"}}' –
ありがとうナンドゥ、正確にどこにパラメータを追加しますか?それはgetメソッドの後ですか? – Lucky500