スマホとPCで、viewを変えて表示したいのですが、
アクセスすると NoMethodError になってしまいます。
ご教授お願いします。
class ApplicationController < ActionController::Base
before_action :set_request_variant
def index
request.user_agent #=> "Mozilla/5.0 (Macintosh; ..."
request.device_type #=> :pc
request.os #=> "Mac OSX"
request.browser #=> "Chrome"
request.from_pc? #=> true
request.from_smartphone? #=> false
end
private
def set_request_variant
request.variant = request.device_variant # :pc, :smartphone
end
end
NoMethodError in HelloController#testAction
undefined method `device_type' for #ActionDispatch::Request:0x007f8373cecdd8
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。