在Ruby on Rails中支持移动设备

时间:2020-11-25 20:08:04

What is the best way to develop a rails application that has special views for different mobile devices? Basically I'm looking for something like this ASP.NET MVC solution: http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx

开发针对不同移动设备的特殊视图的rails应用程序的最佳方法是什么?基本上我要找的就是这样的ASP。NET MVC解决方案:http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx

7 个解决方案

#1


13  

Two articles that use the iPhone as an example of serving up a different view based on a mobile sub-domain or a by detecting the user-agent. Essentially you'll create a different view using something like viewname.iphone.erb or viewname.mobile.erb and set the request.format variable to iphone or mobile respectively.

这两篇文章以iPhone为例,基于移动子域或通过检测用户代理提供不同的视图。基本上,您将使用viewname.iphone等创建一个不同的视图。erb或viewname.mobile。并设置请求。分别为iphone或手机格式化变量。

iPhone subdomains with Rails

用Rails iPhone子域

iPhone on Rails - Creating an iPhone optimised version of your Rails site using iUI and Rails 2

iPhone on Rails——使用iUI和Rails 2创建一个iPhone优化版本的Rails站点

#2


15  

You might be looking for mobile_fu. It's a plugin that automatically changes the Rails format from :html to :mobile for Nokia, Blackberry, iPhone and Palm users. You can then just provide an {action}.mobile.erb to complement {action}.html.erb and it will render the mobile view. If you need something more fine-grained, it allows you to do:

你可能在找mobile_fu。它是一个插件,可以自动将Rails格式从:html转换为:诺基亚(Nokia)、黑莓(Blackberry)、iPhone和Palm用户的手机格式。然后,您可以提供一个{action}.mobile。erb补充{行动} . html。erb,它将呈现移动视图。如果你需要更细粒度的东西,它允许你做:

is_mobile_device?

and there's various other helper methods

还有很多其他的辅助方法

#3


6  

I found this railscast extremely helpful for this situation: http://railscasts.com/episodes/199-mobile-devices

我发现railscast对这种情况非常有用:http://railscasts.com/episode des/199-mobile-devices

Hope it helps somebody out.

希望它能帮助别人。

#4


3  

Ernie Miller wrote a post about how to provide mobile templates for your views. What's nice is that his approach doesn't force you to provide a mobile template if it isn't required. Instead, rails will fall back on your main template if the mobile version isn't found.

Ernie Miller写了一篇关于如何为您的视图提供移动模板的文章。令人高兴的是,他的方法不会迫使您在不需要的情况下提供移动模板。相反,如果找不到移动版本,rails将退回到主模板。

#5


1  

I recently wrote an article about this which you might find useful:

我最近写了一篇关于这方面的文章,你可能会觉得它有用:

http://www.arctickiwi.com/blog/2-mobile-enable-your-ruby-on-rails-site-for-small-screens

http://www.arctickiwi.com/blog/2-mobile-enable-your-ruby-on-rails-site-for-small-screens

Hope that helps

希望这有助于

Jonno

那么默契

#6


1  

I just saw a really illuminating video on this: http://www.engineyard.com/video/12678746 . There is a lot more to a decent mobile web experience then directly porting pages.

我刚刚看到一个很有启发性的视频:http://www.engineyard.com/video/12678746。除了直接移植页面之外,还有很多更好的移动web体验。

#7


1  

You might want to try Mobvious - https://github.com/jistr/mobvious

您可能想尝试Mobvious - https://github.com/jistr/mobvious

Detects mobiles vs. desktops + tablets, or if you want, detects mobile vs. tablets vs. desktops.

检测手机vs桌面+平板电脑,或者如果你想,检测手机vs平板vs桌面。

It also has support for manual selection by users (overriding the detection) if you want to allow users to manually switch interface versions.

它还支持用户手动选择(覆盖检测),如果您希望允许用户手动切换界面版本。

And there is an extension mobvious-rails that adds some helpers to your controllers, views and CoffeeScript.

还有一个扩展mobvious-rails,它向控制器、视图和CoffeeScript添加一些助手。

#1


13  

Two articles that use the iPhone as an example of serving up a different view based on a mobile sub-domain or a by detecting the user-agent. Essentially you'll create a different view using something like viewname.iphone.erb or viewname.mobile.erb and set the request.format variable to iphone or mobile respectively.

这两篇文章以iPhone为例,基于移动子域或通过检测用户代理提供不同的视图。基本上,您将使用viewname.iphone等创建一个不同的视图。erb或viewname.mobile。并设置请求。分别为iphone或手机格式化变量。

iPhone subdomains with Rails

用Rails iPhone子域

iPhone on Rails - Creating an iPhone optimised version of your Rails site using iUI and Rails 2

iPhone on Rails——使用iUI和Rails 2创建一个iPhone优化版本的Rails站点

#2


15  

You might be looking for mobile_fu. It's a plugin that automatically changes the Rails format from :html to :mobile for Nokia, Blackberry, iPhone and Palm users. You can then just provide an {action}.mobile.erb to complement {action}.html.erb and it will render the mobile view. If you need something more fine-grained, it allows you to do:

你可能在找mobile_fu。它是一个插件,可以自动将Rails格式从:html转换为:诺基亚(Nokia)、黑莓(Blackberry)、iPhone和Palm用户的手机格式。然后,您可以提供一个{action}.mobile。erb补充{行动} . html。erb,它将呈现移动视图。如果你需要更细粒度的东西,它允许你做:

is_mobile_device?

and there's various other helper methods

还有很多其他的辅助方法

#3


6  

I found this railscast extremely helpful for this situation: http://railscasts.com/episodes/199-mobile-devices

我发现railscast对这种情况非常有用:http://railscasts.com/episode des/199-mobile-devices

Hope it helps somebody out.

希望它能帮助别人。

#4


3  

Ernie Miller wrote a post about how to provide mobile templates for your views. What's nice is that his approach doesn't force you to provide a mobile template if it isn't required. Instead, rails will fall back on your main template if the mobile version isn't found.

Ernie Miller写了一篇关于如何为您的视图提供移动模板的文章。令人高兴的是,他的方法不会迫使您在不需要的情况下提供移动模板。相反,如果找不到移动版本,rails将退回到主模板。

#5


1  

I recently wrote an article about this which you might find useful:

我最近写了一篇关于这方面的文章,你可能会觉得它有用:

http://www.arctickiwi.com/blog/2-mobile-enable-your-ruby-on-rails-site-for-small-screens

http://www.arctickiwi.com/blog/2-mobile-enable-your-ruby-on-rails-site-for-small-screens

Hope that helps

希望这有助于

Jonno

那么默契

#6


1  

I just saw a really illuminating video on this: http://www.engineyard.com/video/12678746 . There is a lot more to a decent mobile web experience then directly porting pages.

我刚刚看到一个很有启发性的视频:http://www.engineyard.com/video/12678746。除了直接移植页面之外,还有很多更好的移动web体验。

#7


1  

You might want to try Mobvious - https://github.com/jistr/mobvious

您可能想尝试Mobvious - https://github.com/jistr/mobvious

Detects mobiles vs. desktops + tablets, or if you want, detects mobile vs. tablets vs. desktops.

检测手机vs桌面+平板电脑,或者如果你想,检测手机vs平板vs桌面。

It also has support for manual selection by users (overriding the detection) if you want to allow users to manually switch interface versions.

它还支持用户手动选择(覆盖检测),如果您希望允许用户手动切换界面版本。

And there is an extension mobvious-rails that adds some helpers to your controllers, views and CoffeeScript.

还有一个扩展mobvious-rails,它向控制器、视图和CoffeeScript添加一些助手。