0

사용자 에이전트 검색이 작동하도록 사소한 문제가 있습니다. 나는 그것이 작동하지 않습니다 생산에 그것을 시도 할 때마다 .. 그래서 또한 내가 설정하는 방법을 알고 싶습니다 .. 내가 생산 모드에 오전 때레일에서 사용자 에이전트를 자동 검색하는 방법

before_filter :prepare_for_mobile 

private 

def mobile_device? 
    if session[:mobile_param] 
    session[:mobile_param] == "1" 
    else 
    request.user_agent =~ /Mobile|webOS/ 
    end 
end 
helper_method :mobile_device? 

def prepare_for_mobile 
    session[:mobile_param] = params[:mobile] if params[:mobile] 
    request.format = :mobile if mobile_device? 
end 

하지만이 작동하지 않습니다 내 응용 프로그램 컨트롤러이 있습니다 blackberry andriod, iphone, nokias3, bada and windows os 사용자 에이전트. 감사합니다

답변

0

config/environments/production.rb 파일의 사본을 게시 할 수 있습니까?

사이드 참고 : 당신은 아마 (responds_to 블록과), 당신은 XML 또는 JSON 출력을 중단하지 않으려면이 뭔가를 추가 할 :

def prepare_for_mobile 
    if request.format == 'text/html' 
    session[:mobile_param] = params[:mobile] if params[:mobile] 
    request.format = :mobile if mobile_device? 
    end 
end 
관련 문제