Homeland 关于 Grape

kennyworld · 2013年08月22日 · 最后由 zj0713001 回复于 2013年08月22日 · 4510 次阅读

这个出错:

API

gem 'grape', :github => 'intridea/grape', :branch => 'frontier'

=〉 fatal: ambiguous argument 'frontier': unknown revision or path not in the working tree.

那个 branch:frontier 是不是没有了?

自己上 github 看啊,没有了

改成: gem 'grape', '0.4.1' 后,可以正常 gem,但是程序启动不了。 说 grape 未能初始化。

错误信息:

uninitialized constant Grape::Entity (NameError)
  /home/bbsforum/app/grape/entities.rb:5:in `<module:APIEntities>'
  /home/bbsforum/app/grape/entities.rb:4:in `<module:RubyChina>'
  /home/bbsforum/app/grape/entities.rb:3:in `<top (required)>'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/backports-3.3.3/lib/backports/tools.rb:328:in `require'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/backports-3.3.3/lib/backports/tools.rb:328:in `require_with_backports'
  /home/bbsforum/app/grape/api.rb:1:in `<top (required)>'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/backports-3.3.3/lib/backports/tools.rb:328:in `require'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/backports-3.3.3/lib/backports/tools.rb:328:in `require_with_backports'
  /home/bbsforum/config/routes.rb:2:in `block in <top (required)>'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:289:in `instance_exec'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:289:in `eval_block'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:267:in `draw'
  /home/bbsforum/config/routes.rb:1:in `<top (required)>'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `each'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `load_paths'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:16:in `reload!'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/railties-3.2.13/lib/rails/application.rb:108:in `reload_routes!'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/devise-2.2.3/lib/devise/rails.rb:14:in `block in <class:Engine>'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:34:in `call'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `each'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/railties-3.2.13/lib/rails/application/finisher.rb:52:in `block in <module:Finisher>'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
  /home/bbsforum/config/environment.rb:6:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-4.0.14/helper-scripts/rack-preloader.rb:82:in `eval'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-4.0.14/helper-scripts/rack-preloader.rb:82:in `preload_app'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-4.0.14/helper-scripts/rack-preloader.rb:127:in `<module:App>'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-4.0.14/helper-scripts/rack-preloader.rb:6:in `<module:PhusionPassenger>'
  /usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-4.0.14/helper-scripts/rack-preloader.rb:5:in `<main>'
gem "grape", "~> 0.5.0"
gem "grape-entity", "~> 0.3.0"

#4 楼 @zj0713001 修改之后出现新的错误:

undefined method `error_format' for RubyChina::API:Class (NoMethodError)

还缺少什么 gem 吗?

#5 楼 @kennyworld https://github.com/intridea/grape/pull/285 error_format 被删掉了 你直接修改源码改成 format :json 就好了

#6 楼 @zj0713001 终于可以了。 github 上 ruby-china 的 source 是就的吗?gemfile 好像还是旧的。

#7 楼 @kennyworld 这个还真不知道哦 我只拿来学习过... 没部署

需要 登录 后方可回复, 如果你还没有账号请 注册新账号