Heroku, Devise: Getting 'NoMethodError (undefined `to_key' method for: user: Symbol) '

I don't know when this happened, but I get this error NoMethodError (undefined method 'to_key' for :user:Symbol)

This behavior occurs only in Kerok Geroku. I am using Devise (1.4.2) to authenticate via Facebook on Rails 3.1.0.rc6 and ruby ​​1.9.2-p290. This happens on the line with sign_in_and_redirect(:user, authentication.user) . Here is my method:

 def create omniauth = request.env['omniauth.auth'] authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid']) if !authentication.nil? flash[:notice] = I18n.t('devise.omniauth_callbacks.success', kind: omniauth['provider']) sign_in_and_redirect(:user, authentication.user) elsif current_user current_user.authentications.create!(provider: omniauth['provider'], uid: omniauth['uid']) redirect_to profile_path, notice: I18n.t('devise.omniauth_callbacks.success', kind: omniauth['provider']) else user = User.new user.apply_omniauth(omniauth) if user.save flash[:notice] = I18n.t('devise.omniauth_callbacks.success', kind: omniauth['provider']) sign_in_and_redirect(:user, user) else session[:omniauth] = omniauth.except('extra') redirect_to new_user_registration_url end end end 
+6
source share
2 answers

Before doing anything on the local computer, first try restarting the hero:

 $ cd your_app_directory $ heroku restart 

I had exactly the same problem and a simple restart fixed it.

+9
source

I get the exact same error; however, it only started after I configured my hostname in the omniauth.rb initializer like this:

OmniAuth.config.full_host = 'http://hostname.com/subdirectory

I added this because I am running Rails3 w / Passenger in a subdirectory from my root domain. Perhaps you have the same override?

I still need to eliminate the inability of Facebook to handle the subdirectory callback (twitter saves the subdirectory correctly without overriding full_host). Thoughts?

+1
source

Source: https://habr.com/ru/post/895657/


All Articles