Answer the question
In order to leave comments, you need to log in
How to use the podigee/device_detector gem in a Ruby on Rails project?
Good afternoon.
Through IRB in the terminal, the developer's example works fine.
But I can not figure out how to use it in the application.
In models, controller or view?
The task is this:
You need to load different scripts for different devices.
Please tell me how to implement.
request.headers['User-Agent'] - only works in a view. How to write the same in the model?
I understand the logic
def user_agent
user_agent = request.headers['User-Agent']
client = DeviceDetector.new(user_agent)
end
if client.device_type == 'smartphone'
...
else
...
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question