skip before filter dynamically (with condition)


I have mobile web under mobile controller.

And While coming to mobile/index page i need to detect the OS, if the OS
is android redirect to android page and if OS is ios redirect to ios

This i done using before_filter : detect_os

and the pages are redirected properly

My worry is,
under iphone page and android page, i have a button called "No thanks"
and if user clicks on "no thanks" button it should load "mobile/index"

But as i have filter detect_os for index page it loops again and again
if i click "no thanks" button.

Kindly suggest me to skip filter(detect_os) and load mobile/index if
user clicks on "no thanks"

thanks in advance


How about this:

- Have the filter on mobile/index check a slot in the session hash (or
if they're logged in by then, maybe a column in the user preferences
record). Let's call it mobile_choice, so it's session[:mobile_choice]
or current_user.mobile_choice.

  * If there is none, set it to the detected OS and proceed with redirection.

  * Else if the value is "generic", stay there.

  * Else redirect to the index page for the chosen OS.

- On the OS-specific pages, if they click "No thanks" (which you might
not even give them if they weren't redirected), set "generic" as the
value, and redirect to the generic-mobile page.

- Alternately, don't have the generic-mobile index forcibly redirect,
but ask via a popup whether they'd like to be redirected. If they say
no, set the value to "generic" and stay there. Then there's no need
for the additional step of going via the OS-specific page.

I'd suggest that in any case, you give them the ability to switch
among all three options (iOS, Android, and generic mobile), plus maybe
even non-mobile if applicable.