根据设备类型自动渲染页面
添加Gem
gem "browser"定义方法
class ApplicationController < ActionController::Base
before_action :detect_device_variant
def detect_device_variant
# 定义手机端调用
request.variant = :mobile if browser.device.mobile?
# 定义平板,如果需要
request.variant = :tablet if browser.device.tablet?
end
end
配置View
找到需要配置的view
Last updated