Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###(the old way)
- 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
- views/layouts/application.html.erb
- <%= stylesheet_link_tag 'mobile' if mobile_device? %>
- ...
- <p>
- <% if mobile_device? %>
- <%= link_to "Full Site", :mobile => 0 %>
- <% else %>
- <%= link_to "Mobile Site", :mobile => 1 %>
- <% end %>
- </p>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement