Hi I’m not sure how to do chained filters here. Here is my code
before_filter :prepare_for_mobile
protect_from_forgery
private
def mobile_device?
request.user_agent =~ /Mobile|webOS/
end
helper_method :mobile_device?
def prepare_for_mobile
request.format = :mobile if mobile_device?
end
What I want is after :prepare_for_mobile if it’s not a mobile device it will redirect to a normal website and I would like to check if the user is logged in. On mobile version, no users will be required to log in.
And in the normal website, I would like to :except a particular controller as well.
How do I do that?
Thanks a lot.
Well, a couple of things…. It looks like you’re partially implementing the solution from Railscasts.com here (only you’re trying to do it without setting the session parameter??).
You don’t need to ‘chain’ filters. Just create a new function (ex: get_ready) that calls the other two functions in the order you want them, and make that your filter.
If you want to branch behavior within a single site based on mobile, you should do that in the controllers, in the routes, or both. I hope I answered your questions.