3

我在使用 Foreman 和 Thin 启动 Rails-API 应用程序时遇到此错误。

AM@~/Documents/RailsWS/app1229 >foreman start
09:47:39 web.1  | started with pid 773
09:47:44 web.1  | => Booting Thin
09:47:44 web.1  | => Rails 3.2.8 application starting in development on   
  http://0.0.0.0:5000
09:47:44 web.1  | => Call with -d to detach
09:47:44 web.1  | => Ctrl-C to shutdown server
09:47:45 web.1  | Exiting
09:47:45 web.1  | 
 /Users/AM/Documents/RailsWS/app1229/config/initializers/wrap_parameters.rb:8:in 
 `block in <top (required)>': undefined method `wrap_parameters' for 
 ActionController::API:Class (NoMethodError)

在花了几个小时尝试调试它之后,我没有成功,所以最终决定尝试破解:我initializers/wrap_parameters.rb在项目的文件中注释掉了这一行,如下所示:

ActiveSupport.on_load(:action_controller) do
  #wrap_parameters format: [:json] 
end

这似乎解决了当前的问题,瘦服务器启动并运行。但是,我不确定这会对应用程序产生什么影响。在使用 Rabl gem 服务 JSON 的 Rails-API 应用程序中这样做是否安全?

我还参考了Agile Web Development with Rails (Ed. 4) 的 Active Resources 部分

4

1 回答 1

0

我废弃了 rails api 项目,现在我将它重写为一个完整的 rails 应用程序。

于 2012-12-31T04:05:35.563 回答