Mobile version of views for Ruby on Rails

前端 未结 4 1667
长情又很酷
长情又很酷 2020-12-22 20:04

I\'m after some validation that I\'m doing the right thing. I have my Ruby on Rails application in the following structure:

/home
   about.rhtml<

4条回答
  •  误落风尘
    2020-12-22 21:03

    firstly, you should be using .html.erb as your template extension

    secondly you can use logic to detect the type of layout to use based on the user agent (request.user_agent).

    layout :site_layout
    
    def site_layout
      some_way_to_detect_the_layout_to_use
    end
    

    Note, the user_agent can be faked, but a majority of people wont bother faking it so the solution should be "good enough" for 99.9% of cases.

提交回复
热议问题