Invalid number of arguments (2 for 1) error in M.Hartl Rails tutorial 7.4.1

I am following the latest version of M.Hartl Rails tutorial and I ran into the problem in chapter 7.4.1. I have created a registration form that is associated with a new custom controller action. When the form is submitted with valid information, the controller should redirect to the new user profile, however I will incur the error below ...

I have included the route.rb code as well as the user controller code. Can anyone help me?

When I access the url .. / users / 1 , the page does indeed display my user, so I know that the user was created and saved in the database. I don't know, maybe this is a bug in the implementation of the redirect_to method ?

Any help would be greatly appreciated!


ArgumentError in UsersController # create wrong number of arguments (2 for 1)

Extracted source (around line # 19):

private
  def _compute_redirect_to_location_with_xhr_referer(options)
    store_for_turbolinks begin
      if options == :back && request.headers["X-XHR-Referer"]
        _compute_redirect_to_location_without_xhr_referer(request.headers["X-XHR-Referer"])

      


Custom controller:

class UsersController < ApplicationController

  def new
    @user = User.new
  end

  def show
    @user = User.find(params[:id])
  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

      

Routes.rb:

Rails.application.routes.draw do
  root             'static_pages#home'
  get 'help'    => 'static_pages#help'
  get 'about'   => 'static_pages#about'
  get 'contact' => 'static_pages#contact'
  get 'signup'  => 'users#new'
  resources :users
end

      

+3


source to share


1 answer


It looks like your version of turbolinks is out of date. Try updating to the latest version:



gem 'turbolinks', '~> 2.3.0'

+19


source







All Articles