Devise / sessions Controller-Ausgabe - nicht Fixnum in String konvertieren
-
12-10-2019 - |
Frage
Das ist also der Fehler sehe ich:
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'
Dies ist, wie application_controller.rb aussieht:
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
Hilfe
Edit1. Per Antrag, hier ist die Ausgabe der Protokolldatei
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 "/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 "/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)
Wer kommt mit allen möglichen Lösungen für das?
Lösung
Ok, so fand ich endlich die Antwort. Der db bekam beschädigt. Sobald ich die ganze db abgeladen, löschte das db-Datei und neu erstellt alles - ich war gut zu gehen.
seufzen
Ich hoffe nur, dass ich einen Weg herauszufinden, dass in der Produktion geschieht zu verhindern.
Andere Tipps
Sind Sie sicher, dass die folgenden in Ihrer korrekten whatever_controller.rb ist?
before_filter :authenticate_user!
Haben Sie das Datenbank-Kennwort eine reine Zahl zu sein? Meine Datenbank Passwort war 111111
in der devlopment Maschine, nach der Fehlerinfo "can't convert Fixnum into String"
, ich denke, ich sollte Datenbank-Kennwort ändern nicht-numerisch zu sein „abcdef“ und es hat funktioniert!