現在、Hartl(チュートリアル)のチュートリアルを行っており、第7章[7.5.3、具体的には、プロダクションデプロイメント]の最後に詰まっています。ActionController :: ParamaterMissingが実行中です。 Hartlのチュートリアルの第7章から
1) Error:
UsersSignupTest#test_invalid_signup_information:
ActionController::ParameterMissing: param is missing or the value is empty: user
app/controllers/users_controller.rb:24:in `user_params'
app/controllers/users_controller.rb:12:in `create'
test/integration/users_signup_test.rb:8:in `block (2 levels) in <class:UsersSignupTest>'
test/integration/users_signup_test.rb:7:in `block in <class:UsersSignupTest>'
2) Error:
UsersSignupTest#test_valid_signup_information:
ActionController::ParameterMissing: param is missing or the value is empty: user
app/controllers/users_controller.rb:24:in `user_params'
app/controllers/users_controller.rb:12:in `create'
test/integration/users_signup_test.rb:19:in `block (2 levels) in <class:UsersSignupTest>'
test/integration/users_signup_test.rb:18:in `block in <class:UsersSignupTest>'
users_controller.rb
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
end
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
flash[:success] = "Welcome to the Sample App!"
redirect_to @user
else
render 'new'
end
end
private
def user_params
params.require(:user).permit(:name, :email, :password,
:password_confirmation)
end
end
users_signup_test.rb
require 'test_helper'
class UsersSignupTest < ActionDispatch::IntegrationTest
test "invalid signup information" do
get signup_path
assert_no_difference 'User.count' do
post users_path, params: { user: { name: "",
email: "[email protected]",
password: "foo",
password_confirmation: "bar" } }
end
end
test "valid signup information" do
get signup_path
assert_difference 'User.count', 1 do
post users_path, params: { user: { name: "Example User",
email: "[email protected]",
password: "password",
password_confirmation: "password" } }
end
follow_redirect!
assert_template 'users/show'
end
end
どのバージョンのRailsとRSpecを使用しますか? – spickermann