Reputation: 10517
I'm trying to implement simple authorization following by certain tutorial.
class AuthController < ApplicationController
layout 'public'
def auth_user
user = User.authenticate(login_params)
if user
session[:user_id] = user.id
redirect_to(:action => 'home')
else
flash[:notice] = "wrong username or password"
flash[:color]= "invalid"
render "login"
end
end
private
def login_params
params.require(:login_data, :password)
end
end
and getting the exception at params.require saying 'wrong number of arguments (2 for 1)'. can't understand, what am I doing wrong? rails 4.1.1
Upvotes: 0
Views: 2362
Reputation: 29281
The require
method, or more specifically ActionController::Parameters#require
, only takes a param key as argument.
As you can see from the Rails 4.1.1 source code:
# File actionpack/lib/action_controller/metal/strong_parameters.rb, line 172
def require(key)
self[key].presence || raise(ParameterMissing.new(key))
end
Upvotes: 2