ruby-on-railsruby-on-rails-3devisedeclarative-authorization

Can't convert Fixnum into String - Devise/sessions Controller issue


So this is the error I see:

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'

This is how application_controller.rb looks:

    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

Help!

Edit1: Per the request, here is the output of the log file.

    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)

Anyone come up with any solutions for this?


Solution

  • Ok so I finally found the answer. The db got corrupt. Once I dumped the entire db, deleted the db file and re-created everything - I was good to go.

    sigh

    I just hope I can figure out a way to prevent that from happening in production.