常规的Rails应用程序和Rails API有什么区别? [英] What is the difference between a regular Rails app and a Rails API?

查看:82
本文介绍了常规的Rails应用程序和Rails API有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在学习Rails的过程中,我了解了如何将其与某些前端MV * JavaScript框架(例如Backbone.js,Angular.js或Ember.js)结合以改善UX.

In the process of learning Rails, I read about how we could combine it with some front-end MV* JavaScript frameworks — such as Backbone.js, Angular.js, or Ember.js — to improve the UX.

这向我介绍了使用Rails作为API而不是Web应用程序的概念.

This introduced (to me) the concept of using Rails as an API, instead of a web app.

所以,现在,我很困惑:常规的Rails应用程序和Rails API有什么区别?

So, now, I am pretty confused: what is the difference between a regular Rails app and a Rails API?

推荐答案

我在Yoni Weisbrod的

I found a pretty clear answer in Yoni Weisbrod's Rails API Mini Guide:

API与常规Rails应用之间的根本区别是 API返回的数据用于进一步处理,而不是返回 可以直接查看.因此,与其产生一个 外观漂亮的HTML文档(带有CSS和/或Javascript),API 产生可以由以下人员进一步处理的简单信息结构 会消耗我们API的任何东西.

The fundamental difference between an API and a regular Rails app is that an API returns data for further processing, rather than data that is meant to be viewed directly. Therefore, rather than producing an HTML document (with CSS and/or Javascript) that looks pretty, APIs produce simple information structures that can be further processed by whatever will be consuming our API.

这篇关于常规的Rails应用程序和Rails API有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆