読者です 読者をやめる 読者になる 読者になる

Satomi and Dogs

バーチャルな世界に住んでいた料理好きSatomiが美味しいご飯と犬と動物たちと牧草に囲まれた生活を目指す日記です

When you want to use url with locale, OAuth using Devise & OmniAuth has error at callback. How to resolve?

Edit config/routes.rb, set only ominauth_callbacks outside of scope of locale.

Rails.application.routes.draw do
  devise_for :users,
  skip: [
    :session,
    :password,
    :registration,
    :confirmation
  ],
  controllers: {
    omniauth_callbacks: 'users/omniauth_callbacks'
  }

  scope '(:locale)', locale: /en/ do
    get 'omniauth/:provider' => 'users/omniauth#localized', as: :localized_omniauth
    devise_for :users,
    skip: :omniauth_callbacks,
    controllers: {
      sessions:            'users/sessions',
      registrations:       'users/registrations',
      passwords:           'users/passwords',
      confirmations:       'users/confirmations'
    }
end