使用 Rails 为 API 构建前端(MVC "model" 是外部 API 而不是数据库)
Using Rails to build a frontend for an API (the MVC "model" is an external API not a database)
我看到很多关于使用 Rails 构建仅 API 后端的文章、帖子和视频,该后端被各种可能的前端技术(React、Angular、Vue 等)。
但是,如果所需的前端应用程序之一是单独的、独立的 前端,用于使用 Rails 构建的 API,是否有任何有助于创建“常规”Rails MVC 应用程序的工具、gems 或技术,我想除了控制器 CRUD 操作用 API 调用替换 ActiveRecord?
一个用例示例可能是 消费者 使用的 Web 和移动前端将使用 Vue.js 或 React。但是完全独立的“管理器”前端应用程序使用 Rails 可以更快地开发和更容易维护,同时仍然严格执行后端/前端分离。
有ActiveResource。根据概述:
Model classes are mapped to remote REST resources by Active Resource much the same way Active Record maps model classes to database tables. When a request is made to a remote resource, a REST JSON request is generated, transmitted, and the result received and serialized into a usable Ruby object.
我很久以前就尝试过 ActiveResource。最后,我自己滚了。
我看到很多关于使用 Rails 构建仅 API 后端的文章、帖子和视频,该后端被各种可能的前端技术(React、Angular、Vue 等)。
但是,如果所需的前端应用程序之一是单独的、独立的 前端,用于使用 Rails 构建的 API,是否有任何有助于创建“常规”Rails MVC 应用程序的工具、gems 或技术,我想除了控制器 CRUD 操作用 API 调用替换 ActiveRecord?
一个用例示例可能是 消费者 使用的 Web 和移动前端将使用 Vue.js 或 React。但是完全独立的“管理器”前端应用程序使用 Rails 可以更快地开发和更容易维护,同时仍然严格执行后端/前端分离。
有ActiveResource。根据概述:
Model classes are mapped to remote REST resources by Active Resource much the same way Active Record maps model classes to database tables. When a request is made to a remote resource, a REST JSON request is generated, transmitted, and the result received and serialized into a usable Ruby object.
我很久以前就尝试过 ActiveResource。最后,我自己滚了。