그래서이 오류가 내가 볼 수 있습니다 :는 문자열로 Fixnum이라는 변환 할 수 없습니다 - 고안/세션 컨트롤러 문제
TypeError in Devise/sessionsController#create
can't convert Fixnum into String
Application Trace | Framework Trace | Full Trace
app/controllers/application_controller.rb:21:in `set_current_user'
이 얼마나 application_controller.rb 외모 :
class ApplicationController < ActionController::Base
helper :all
helper_method :current_user, :logged_in?
protect_from_forgery
before_filter :set_current_user
def set_xhr_flash
flash.discard if request.xhr?
end
def correct_safari_and_ie_accept_headers
ajax_request_types = ['text/javascript', 'application/json', 'text/xml']
request.accepts.sort! { |x, y| ajax_request_types.include?(y.to_s) ? 1 : -1 } if request.xhr?
end
protected
def set_current_user
Authorization.current_user = current_user
end
end
도움말을!
편집 1 : 요청에 따라 여기에 로그 파일의 출력이 있습니다.
User Load (0.3ms) SELECT "users".* FROM "users" WHERE ("users"."username" = 'test') LIMIT 1
Completed in 289ms
TypeError (can't convert Fixnum into String):
app/controllers/application_controller.rb:21:in `set_current_user'
Rendered /Users/marcamillion/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.2ms)
Rendered /Users/marcamillion/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (340.7ms)
Rendered /Users/marcamillion/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (350.6ms)
Started GET "https://stackoverflow.com/users/login" for 127.0.0.1 at 2011-01-19 17:16:18 -0500
Processing by Devise::SessionsController#new as HTML
nil
Rendered devise/sessions/new.html.erb within layouts/application (5.9ms)
Completed 200 OK in 65ms (Views: 15.6ms | ActiveRecord: 0.0ms)
Started POST "https://stackoverflow.com/users/login" for 127.0.0.1 at 2011-01-19 17:16:31 -0500
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"+SYzwvqO1Kp8GhYwSA9u3plM5A/RNNRFT3wzJICXP6s=", "user"=>{"f_name"=>"First Name", "l_name"=>"Last Name", "username"=>"test", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "email"=>"Email Address"}, "commit"=>"Submit"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE ("users"."username" = 'test') LIMIT 1
Completed in 199ms
TypeError (can't convert Fixnum into String):
app/controllers/application_controller.rb:21:in `set_current_user'
Rendered /Users/marcamillion/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.2ms)
Rendered /Users/marcamillion/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (348.3ms)
Rendered /Users/marcamillion/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (355.7ms)
누구나 어떤 해결책을 제시할까요?
set_current_user에서'Authorization.current_user = current_user' 앞에'logger.info current_user.inspect'를 추가하고 로그 파일에 출력을 질문에 추가 할 수 있습니까? –
@Brett Bender Done. 업데이트 된 질문보기 – marcamillion
이상하다. 그 로거 호출의 출력은 SessionsController # new에 nil이된다. (현재 사용자가 없다면 올바르다.) POST 요청에서 그 로거 호출의 출력은 없다. SessionsController # create - 아마도 set_current_user가 호출되지 않을 것입니까? 오류가 SessionsController # create에 대한 게시 요청에 던져지기 전에 일부 디버깅 출력을 얻으려고합니다. 분명히 # 새로운 동작은 예상대로 작동합니다. 더 많이 도울 수 있기를 바랍니다. –