Backbone.js前端有RESTful Rails后端吗?

时间:2022-01-19 16:22:18

I started in the web development world with PHP, and then Rails in the recent few years. Since then I've been doing all my web projects in Rails.

我开始使用PHP开发Web开发世界,然后在最近几年开始使用Rails。从那时起,我一直在Rails中完成所有的Web项目。

Recently there seems to be a movement towards making Rails as a pure RESTful backend service and using frontend framework such as Backbone.js for all frontend interaction. I'm wondering what's you guys' take on it? Will this be the eventual future?

最近,似乎有一种趋势,即将Rails作为纯RESTful后端服务,并使用Backbone.js等前端框架进行所有前端交互。我想知道你们对它们有什么看法?这将是最终的未来吗?

As well, besides Backbone.js, what are some other alternatives for frontend framework for this purpose?

同样,除了Backbone.js之外,为此目的还有哪些其他前端框架的替代方案?

Also assuming that I will want to support both a desktop version and a mobile version of my app, would this be a proper route to take? So I'll have a single backend service with different frontend services? This way I don't need to manage all the views on Rails' side?

另外假设我想支持我的应用程序的桌面版和移动版,这是一条合适的路线吗?那么我将拥有一个具有不同前端服务的后端服务?这样我就不需要管理Rails方面的所有视图了?

Thanks!

谢谢!

3 个解决方案

#1


19  

For Client-side frameworks, this article has a list of 20 of them with pro's and con's: http://net.tutsplus.com/articles/web-roundups/20-javascript-frameworks-worth-checking-out/

对于客户端框架,本文列出了20个具有pro和con的框架:http://net.tutsplus.com/articles/web-roundups/20-javascript-frameworks-worth-checking-out/

Here's the list:

这是列表:

  1. Backbone.js
  2. Backbone.js的
  3. Knockout.js
  4. Knockout.js
  5. Asana luna
  6. Asana luna
  7. Cappucino
  8. 卡布奇诺
  9. Sproutcore
  10. SproutCore的
  11. BatmanJS
  12. BatmanJS
  13. corMVC
  14. corMVC
  15. TrimJunction
  16. TrimJunction
  17. pureMVC
  18. PureMVC的
  19. jamal
  20. 贾马尔
  21. choco
  22. 巧克力
  23. sammyjs
  24. sammyjs
  25. extJS
  26. EXTJS
  27. agilityJS
  28. agilityJS
  29. eyeballs
  30. 眼球
  31. activejs
  32. activejs
  33. spinejs
  34. spinejs
  35. qooxdoo
  36. 的Qooxdoo

These are roughly all about creating client-side, ajax-based, javascript MVC frameworks.

这些大致都是关于创建基于客户端,基于ajax的javascript MVC框架。

If you're looking to start somewhere, then I recommend thinking about Client-Side Templates (...ates...ates...ates) (just the "V") to support a service-oriented architecture (many clients are supported by service-endpoints you create).

如果你想从某个地方开始,那么我建议考虑客户端模板(... ates ... ates ... ates)(只是“V”)以支持面向服务的架构(许多客户端都是由您创建的服务端点支持)。

It's a new technique that involves modularizing your client-side code, bringing MVC to the client, and let business-logic live in the platform. A lot of Software-as-a-Service applications are leveraging them, and with the increasing sophisticated of javascript libraries and frameworks, as well as browser capabilities with HTML5, CSS3, etc. there's going to be an increasing sophistication in client-side presentation.

这是一种新技术,它涉及模块化客户端代码,将MVC引入客户端,并让业务逻辑存在于平台中。许多软件即服务应用程序正在利用它们,随着javascript库和框架的日益复杂,以及HTML5,CSS3等的浏览器功能,客户端演示中的复杂程度将越来越高。 。

So learn it.

所以学习它。

What are the benefits?

有什么好处?

To paraphrase Linked In: for leveraging browser-caching, de-coupling your front-end client-side presentation, asynchronous load, progressive rendering (for some frameworks), performance, ajax-interaction, and more.

解释Linked In:利用浏览器缓存,解耦前端客户端表示,异步加载,渐进式渲染(对于某些框架),性能,ajax交互等。

Several great frameworks include:

几个伟大的框架包括:

  1. mustache
  2. 胡子
  3. dust.js
  4. dust.js
  5. handlebars
  6. 车把
  7. Google Closure Templates
  8. Google Closure模板
  9. Nun
  10. 尼姑
  11. Mu
  12. kite
  13. 风筝

I highly recommend looking at Linked In's move away from JSP towards Client-Side Templates and why they choose dust.js in Linked In's front-end client-side templates throwdown for a comparison. They go into much greater detail, and research, as to why they changed their stack to support this (it involved using 3 server-side technologies), as well as their comparisons of all the frameworks they could find.

我强烈建议看看Linked In从JSP转向客户端模板,以及为什么他们在Linked In的前端客户端模板中选择dust.js进行比较。他们进行了更详细的研究,并研究了为什么他们改变了堆栈以支持这一点(它涉及使用3种服务器端技术),以及他们可以找到的所有框架的比较。

#2


2  

I did something like this a few years ago in .net. Is was not via proper .NET MVC and didn't use the new JS frameworks, but the principle was the same; server code returns JSON to javascript which builds the page and interactions etc.

几年前我在.net做过类似的事。是不是通过适当的.NET MVC并没有使用新的JS框架,但原则是相同的;服务器代码将JSON返回给构建页面和交互等的javascript。

The result was a lovely responsive website, but, maintenance was a nightmare. Be very careful to keep your JS code well organised.

结果是一个可爱的响应式网站,但是,维护是一场噩梦。要非常小心,以保持JS代码组织良好。

Personally, I find it easier to maintain server code (in any language) than javascript so I wouldn't go down that route again.

就个人而言,我发现维护服务器代码(使用任何语言)比javascript更容易,所以我不会再次沿着那条路走下去了。

(IMHO)

(恕我直言)

Fran

弗兰

#3


2  

It is my opinion that contemporary web applications are moving towards this model of having RESTful back-end and all the view interactions coded in front-end. These free video tutorials from Joe Zim:

我认为当代Web应用程序正朝着这种具有RESTful后端和前端编码的所有视图交互的模式发展。这些来自Joe Zim的免费视频教程:

http://www.joezimjs.com/javascript/introduction-to-backbone-js-part-1-models-video-tutorial/

http://www.joezimjs.com/javascript/introduction-to-backbone-js-part-1-models-video-tutorial/

helped me understand backbone and how it can simplify templating and view renders.

帮助我理解主干以及它如何简化模板和查看渲染。

#1


19  

For Client-side frameworks, this article has a list of 20 of them with pro's and con's: http://net.tutsplus.com/articles/web-roundups/20-javascript-frameworks-worth-checking-out/

对于客户端框架,本文列出了20个具有pro和con的框架:http://net.tutsplus.com/articles/web-roundups/20-javascript-frameworks-worth-checking-out/

Here's the list:

这是列表:

  1. Backbone.js
  2. Backbone.js的
  3. Knockout.js
  4. Knockout.js
  5. Asana luna
  6. Asana luna
  7. Cappucino
  8. 卡布奇诺
  9. Sproutcore
  10. SproutCore的
  11. BatmanJS
  12. BatmanJS
  13. corMVC
  14. corMVC
  15. TrimJunction
  16. TrimJunction
  17. pureMVC
  18. PureMVC的
  19. jamal
  20. 贾马尔
  21. choco
  22. 巧克力
  23. sammyjs
  24. sammyjs
  25. extJS
  26. EXTJS
  27. agilityJS
  28. agilityJS
  29. eyeballs
  30. 眼球
  31. activejs
  32. activejs
  33. spinejs
  34. spinejs
  35. qooxdoo
  36. 的Qooxdoo

These are roughly all about creating client-side, ajax-based, javascript MVC frameworks.

这些大致都是关于创建基于客户端,基于ajax的javascript MVC框架。

If you're looking to start somewhere, then I recommend thinking about Client-Side Templates (...ates...ates...ates) (just the "V") to support a service-oriented architecture (many clients are supported by service-endpoints you create).

如果你想从某个地方开始,那么我建议考虑客户端模板(... ates ... ates ... ates)(只是“V”)以支持面向服务的架构(许多客户端都是由您创建的服务端点支持)。

It's a new technique that involves modularizing your client-side code, bringing MVC to the client, and let business-logic live in the platform. A lot of Software-as-a-Service applications are leveraging them, and with the increasing sophisticated of javascript libraries and frameworks, as well as browser capabilities with HTML5, CSS3, etc. there's going to be an increasing sophistication in client-side presentation.

这是一种新技术,它涉及模块化客户端代码,将MVC引入客户端,并让业务逻辑存在于平台中。许多软件即服务应用程序正在利用它们,随着javascript库和框架的日益复杂,以及HTML5,CSS3等的浏览器功能,客户端演示中的复杂程度将越来越高。 。

So learn it.

所以学习它。

What are the benefits?

有什么好处?

To paraphrase Linked In: for leveraging browser-caching, de-coupling your front-end client-side presentation, asynchronous load, progressive rendering (for some frameworks), performance, ajax-interaction, and more.

解释Linked In:利用浏览器缓存,解耦前端客户端表示,异步加载,渐进式渲染(对于某些框架),性能,ajax交互等。

Several great frameworks include:

几个伟大的框架包括:

  1. mustache
  2. 胡子
  3. dust.js
  4. dust.js
  5. handlebars
  6. 车把
  7. Google Closure Templates
  8. Google Closure模板
  9. Nun
  10. 尼姑
  11. Mu
  12. kite
  13. 风筝

I highly recommend looking at Linked In's move away from JSP towards Client-Side Templates and why they choose dust.js in Linked In's front-end client-side templates throwdown for a comparison. They go into much greater detail, and research, as to why they changed their stack to support this (it involved using 3 server-side technologies), as well as their comparisons of all the frameworks they could find.

我强烈建议看看Linked In从JSP转向客户端模板,以及为什么他们在Linked In的前端客户端模板中选择dust.js进行比较。他们进行了更详细的研究,并研究了为什么他们改变了堆栈以支持这一点(它涉及使用3种服务器端技术),以及他们可以找到的所有框架的比较。

#2


2  

I did something like this a few years ago in .net. Is was not via proper .NET MVC and didn't use the new JS frameworks, but the principle was the same; server code returns JSON to javascript which builds the page and interactions etc.

几年前我在.net做过类似的事。是不是通过适当的.NET MVC并没有使用新的JS框架,但原则是相同的;服务器代码将JSON返回给构建页面和交互等的javascript。

The result was a lovely responsive website, but, maintenance was a nightmare. Be very careful to keep your JS code well organised.

结果是一个可爱的响应式网站,但是,维护是一场噩梦。要非常小心,以保持JS代码组织良好。

Personally, I find it easier to maintain server code (in any language) than javascript so I wouldn't go down that route again.

就个人而言,我发现维护服务器代码(使用任何语言)比javascript更容易,所以我不会再次沿着那条路走下去了。

(IMHO)

(恕我直言)

Fran

弗兰

#3


2  

It is my opinion that contemporary web applications are moving towards this model of having RESTful back-end and all the view interactions coded in front-end. These free video tutorials from Joe Zim:

我认为当代Web应用程序正朝着这种具有RESTful后端和前端编码的所有视图交互的模式发展。这些来自Joe Zim的免费视频教程:

http://www.joezimjs.com/javascript/introduction-to-backbone-js-part-1-models-video-tutorial/

http://www.joezimjs.com/javascript/introduction-to-backbone-js-part-1-models-video-tutorial/

helped me understand backbone and how it can simplify templating and view renders.

帮助我理解主干以及它如何简化模板和查看渲染。