What is the difference between a regular Rails app and a Rails API?

前端 未结 3 630
时光取名叫无心
时光取名叫无心 2021-01-02 18:58

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 impr

3条回答
  •  醉话见心
    2021-01-02 19:44

    According to the official rails website, there are three main differences between a rails web application and a rails api:

    1 - The api app is configured to start with a more limited set of middlewares than normal. Specifically, it will not include any middleware primarily useful for browser applications (like cookies support) by default

    2 - In the api app, ApplicationController inherits from ActionController::API instead of ActionController::Base. As with middlewares, this will leave out any Action Controller modules that provide functionalities primarily used by browser applications.

    3 - The api app is configures the generators to skip generating views, helpers and assets when you generate a new resource.

    You can always convert your rails app from either one of these to the other one. To do so, follow the steps in the reference I mentioned above.

提交回复
热议问题