In a Rails 3.2 application, I want to create some types (and actions) specific to mobile devices. So I created a namespace called mobile.
namespace :mobile do
resources :sessions
resources :areas
end
For example, if a user goes to the login page using a mobile device, I want to use the controller and views that I create for this namespace.
So now I have two ways to log in:
new_mobile_session GET /mobile/sessions/new(.:format) mobile/sessions
and
new_session GET /sessions/new(.:format) sessions
But when requests come in, how can I add a “mobile” namespace to a request if it comes from a mobile?
those. change / sessions / new in / mobile / sessions / new
I am using Rack :: MobileDetect, but I do not know how to use redirect_to for this purpose.
config.middleware.use Rack::MobileDetect, :redirect_to => '/mobile'
Or should I use a different approach?
Thank.