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

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

问题描述

在学习 Rails 的过程中,我了解到我们如何将其与一些前端 MV* JavaScript 框架(例如 Backbone.js、Angular.js 或 Ember.js)结合以改进用户体验.

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 的 Rails API 迷你指南:

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天全站免登陆