我们可以使用 Ruby on rails 开发移动应用程序吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4075610/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 23:32:00  来源:igfitidea点击:

Can we use Ruby on rails to develop a mobile app?

ruby-on-railsrubyjruby

提问by Hemanth

Since rails uses MVC acrhitecture. I was wondering that if we can use Rails to develop a mobile app or any web app.
Out of MVC the 'M' and 'C' won't change to develop the mobile app right?
I mean the models and controllers will remain the web-server.
Only the view portion should be changed such that , istead using html.erb files I want java or android sdk or whatever, to provide the UI for the mobile user.

由于 rails 使用 MVC 架构。我想知道我们是否可以使用 Rails 开发移动应用程序或任何 Web 应用程序。
在 MVC 之外,“M”和“C”不会改变以开发移动应用程序,对吗?
我的意思是模型和控制器将仍然是网络服务器。
只应更改视图部分,以便使用 html.erb 文件,我想要 java 或 android sdk 或其他文件,为移动用户提供 UI。

Can some enlighten me on this perspective. Also I have been hearing about Jrbuy does it come into play for our mobile app development requirement. ?

能否从这个角度启发我。我也听说过 Jrbuy 它是否对我们的移动应用程序开发要求起作用。?

采纳答案by rwilliams

The answer to this question is going to depend on how you want to deploy this app. Do you want it running completely on the phone or can it be a web app disguised as an iphone/android app?

这个问题的答案将取决于您希望如何部署此应用程序。您希望它完全在手机上运行,​​还是可以伪装成 iphone/android 应用程序的网络应用程序?

For the native app solution I'd checkout the Rhodes Framework. It's not RoR but you'll see that it's an MVC framework that feels similar. This will allow you to build native iphone/android apps using Ruby.

对于本机应用程序解决方案,我会检查Rhodes Framework。它不是 RoR,但您会发现它是一个感觉相似的 MVC 框架。这将允许您使用 Ruby 构建本机 iphone/android 应用程序。

For the 2nd option, web app disguised as a mobile app, I'd recommend Sencha Touch. Sencha has done an amazing job mimicking the look and feel of native iphone/android apps with their Javascript library. With this solution it would be just like any other web app though it's targeted for android and iphone via it's UI.

对于第二个选项,伪装成移动应用程序的网络应用程序,我推荐Sencha Touch。Sencha 做了一个了不起的工作,用他们的 Javascript 库模仿了原生 iphone/android 应用程序的外观和感觉。有了这个解决方案,它就像任何其他网络应用程序一样,虽然它通过它的用户界面针对 android 和 iphone。

回答by joscas

I've created an example rails/ ember.jsApp that is exported with Phonegap. It uses just the usual MVC architecture of a Rails and an Ember.js App. Maybe you will find it useful. It also implements token authentication based on ember-auth and several OAuth strategies.

我创建了一个使用Phonegap导出的示例rails/ ember.js应用程序。它仅使用 Rails 和 Ember.js 应用程序的常用 MVC 架构。也许你会发现它很有用。它还实现了基于 ember-auth 和几种 OAuth 策略的令牌认证。

Currently in de the devel branch: https://github.com/joscas/base_app/tree/devel

目前在 de devel 分支:https: //github.com/joscas/base_app/tree/devel

Heroku deploy: https://starter-app-staging.herokuapp.com(the desktop version)

Heroku 部署:https: //starter-app-staging.herokuapp.com(桌面版)

Exported with phonegap-railsgem (of which I'm also the author) for assets, fix paths etc.

使用phonegap-railsgem(我也是作者)导出资产,修复路径等。

回答by Ravi Kant

Absolutly YES!

绝对是的!

Ruby on Rails just a backend tech, is the same as what you plan to do for normal browser. There are only two things that you need to consider about mobile app. First is mobile browser's content size because you need to adjust your layout to fit the size. There is a HTML meta tag called viewport can help you.

Ruby on Rails 只是一种后端技术,与您计划为普通浏览器所做的相同。关于移动应用程序,您只需要考虑两件事。首先是移动浏览器的内容大小,因为您需要调整布局以适应大小。有一个名为 viewport 的 HTML 元标记可以帮助您。

Ex.

前任。

This script will tell user's browser that the content should be fit the devise size,initial-scale defines the viewport rate and maximum-scale defines how many times this page can scale, and user-scalble=0 means user cannot scale the page. More about viewport you can check the Mozilla's doc.

这个脚本会告诉用户的浏览器内容应该适合设备大小,initial-scale 定义了视口率,maximum-scale 定义了这个页面可以缩放的次数,user-scalble=0 表示用户不能缩放页面。有关视口的更多信息,您可以查看 Mozilla 的文档。

The other thing you need to consider is the HTML5 techs, but actually these aren't problems when you are using jQuery mobile. I recommend you to check their docs. This is very useful and clear for anyone.

您需要考虑的另一件事是 HTML5 技术,但实际上当您使用 jQuery mobile 时,这些都不是问题。我建议您查看他们的文档。这对任何人来说都非常有用且清晰。

回答by Priyanka Chabbi

Yes you can . Your view can be an web page/android/ ios application as view.

是的你可以 。您的视图可以是作为视图的网页/android/ios 应用程序。

回答by Sergey

RubyonRails is web application framework - it is running on server and user observer the result of application built on RubyOnRails inside browser(or Browser component), despite the fact that you can process on server just "M" from "MVC", and implement "V" and "C" fully on client side( in mobile browser).

RubyonRails 是 Web 应用程序框架 - 它在服务器和用户观察者上运行,这是在浏览器(或浏览器组件)内构建在 RubyOnRails 上的应用程序的结果,尽管您可以在服务器上处理来自“MVC”的“M”,并实现“ V" 和 "C" 完全在客户端(在移动浏览器中)。

In theory, you can fully deploy RubyOnRails application on client side( even RubyOnRails server and etc), but it will be rather expensive and hard, but it is could not be require in any rational project.

理论上,您可以在客户端(甚至 RubyOnRails 服务器等)完全部署 RubyOnRails 应用程序,但它会相当昂贵和困难,但在任何合理的项目中都不会需要。

assuming: There are two way you can choose:

假设:您可以选择两种方式:

  1. Organize RubyonRails application on the server(process there Model), and process "V" and "C" on client side with any proper js libraries.
  2. You can develop Ruby(not RubyOnRails application) - at least it is possible to develop for Android with JRuby.
  1. 在服务器上组织 RubyonRails 应用程序(在那里处理模型),并在客户端使用任何适当的 js 库处理“V”和“C”。
  2. 您可以开发 Ruby(不是 RubyOnRails 应用程序)——至少可以使用 JRuby 为 Android 开发。

回答by Franck Verrot

You may want to try jQuery Mobile (which is still in alpha by now) if it's just a matter of UI. If you need a tighter integration with your mobile, I don't think that running Rails would be efficient enough.

如果只是 UI 问题,您可能想尝试 jQuery Mobile(目前仍处于 alpha 阶段)。如果您需要与您的移动设备进行更紧密的集成,我认为运行 Rails 还不够高效。

回答by PONCY

Try using React Native, the backend technology can still be Ruby while the front-end can use React Native to build mobile app both Android and iOS.

尝试使用 React Native,后端技术仍然可以是 Ruby,而前端可以使用 React Native 构建 Android 和 iOS 移动应用程序。

React Native

反应本机