I tried the first solution, but I could not get it to work. After a long search, I found out that Omniauth has an option:: setup => true, which allows you to dynamically configure arguments, such as the display option for Facebook OAuth.
First enable the: setup option.
config.omniauth :facebook, APP_CONFIG["fb_app_id"], APP_CONFIG["fb_app_secret"], {:scope => 'email, offline_access', :setup => true}
Then add the second route (installation route):
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } do get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru' get '/users/auth/:provider/setup' => 'users/omniauth_callbacks#setup' end
Add this controller. You may already have this if you followed the development guide.
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController def setup request.env['omniauth.strategy'].options[:display] = mobile_device? ? "touch" : "page" render :text => "Setup complete.", :status => 404 end end
Add this method to your ApplicationController:
def mobile_device? if session[:mobile_param] session[:mobile_param] == "1" else request.user_agent =~ /Mobile|webOS/ end end
Done!
Andrei Erdoss
source share