Search code examples
ruby-on-railsrubyruby-on-rails-3devisegeokit

after_sign_in_path_for action not loading Geokit in Rails


Im trying to refresh the Geokit location to session after the user sign in. I have the following code.

# app/controllers/application_controller.rb
def after_sign_in_path_for(resource_or_scope)
  session[:geo_location] = User.geocode(current_user.city)
end

But I'm getting the following error.

NoMethodError in Devise::SessionsController#create

undefined method `model_name' for Geokit::GeoLoc:Class

Seems like Geokit is not loading before the devise controller. Any idea?


Solution

  • The problem is after_sign_in_path_for must return a valid an url object and you are not doing it check its documentation.