I have a method in my model which should detect the User Agent. How can I make it available to all my controller methods?
Model:
def is_iphone_request?
if request.user_agent =~ /iPhone/
return true
end
end
Controller (throws an error):
def index
@user_agent = is_iphone_request?
end
How can I achieve this? Any help is much appreciated.
Put the method in your
ApplicationControllerinstead of in a model.