Skip before filter dynamically (with condition)

Hi,

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
page.

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”
page…

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

Regards,
Jose

On Mon, Feb 18, 2013 at 7:35 AM, martin devapitchai
[email protected] wrote:

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

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.

-Dave


Dave A., the T. Rex of Codosaurus LLC,
secret-cleared freelance software developer
taking contracts in or near NoVa or remote.
See information at http://www.Codosaur.us/.