我一直试图弄清楚这个错误消息的含义,但无法弄清楚。
这是完整的消息
DEPRECATION WARNING: Passing a template handler in the template name
is deprecated. You can simply remove the handler name or pass render
:handlers => [:jbuilder] instead. (called from realtime at
/Users/Arel/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/benchmark.rb:295)
这是代码:
it "is logged in" do
post "/api/v1/login", user_login: {email: 'test@test.com', password: '12345678' }
response.status.should be(201)
end
什么是 a template handler
,为什么它认为我在传递它template name
?什么模板?
编辑:
Sessions_controller
. 登录路径调用的控制器。
class Api::V1::SessionsController < Devise::SessionsController
before_filter :authenticate_user!, except: [:create, :destroy]
before_filter :ensure_params_exist
skip_before_filter :verify_authenticity_token
def create
resource = User.find_for_database_authentication(email: params[:user_login][:email])
return invalid_login_attempt unless resource
if resource.valid_password?(params[:user_login][:password])
sign_in("user", resource)
resource.ensure_authentication_token!
render 'api/v1/sessions/new.json.jbuilder', status: 201
return
end
invalid_login_attempt
end
def destroy
current_user.reset_authentication_token
render json: {success: true}
end
protected
def ensure_params_exist
return unless params[:user_login].blank?
render json: {success: false, message: "missing user_login parameter"}, status: 422
end
def invalid_login_attempt
render 'api/v1/sessions/invalid.json.jbuilder', status: 401
end
end