Rails grape-entity 非常奇怪的问题, 问题出现之后重启 rails s 就好了

kingwkb · 2014年10月22日 · 2902 次阅读

本地开发环境

出现这个问题,重启下 rails s 就又好了

google 了也没个结果

报错如下

NoMethodError (undefined method `represent' for #<Class:0x007fa3702a1258>):
  activerecord (4.2.0.beta2) lib/active_record/dynamic_matchers.rb:26:in `method_missing'
  grape-entity (0.4.4) lib/grape_entity/entity.rb:520:in `value_for'
  grape-entity (0.4.4) lib/grape_entity/entity.rb:460:in `block in serializable_hash'
  grape-entity (0.4.4) lib/grape_entity/entity.rb:458:in `each'
  grape-entity (0.4.4) lib/grape_entity/entity.rb:458:in `inject'
  grape-entity (0.4.4) lib/grape_entity/entity.rb:458:in `serializable_hash'
  grape-entity (0.4.4) lib/grape_entity/entity.rb:482:in `to_json'
  grape (0.9.0) lib/grape/formatter/json.rb:6:in `call'
  grape (0.9.0) lib/grape/middleware/formatter.rb:33:in `block in after'
  grape (0.9.0) lib/grape/middleware/formatter.rb:32:in `collect'
  grape (0.9.0) lib/grape/middleware/formatter.rb:32:in `after'
  grape (0.9.0) lib/grape/middleware/base.rb:25:in `call!'
  grape (0.9.0) lib/grape/middleware/base.rb:18:in `call'
  grape (0.9.0) lib/grape/middleware/base.rb:24:in `call!'
  grape (0.9.0) lib/grape/middleware/base.rb:18:in `call'
  grape (0.9.0) lib/grape/middleware/error.rb:27:in `block in call!'
  grape (0.9.0) lib/grape/middleware/error.rb:26:in `catch'
  grape (0.9.0) lib/grape/middleware/error.rb:26:in `call!'
  grape (0.9.0) lib/grape/middleware/base.rb:18:in `call'
  rack (1.6.0.beta) lib/rack/head.rb:13:in `call'
  rack (1.6.0.beta) lib/rack/builder.rb:153:in `call'
  grape (0.9.0) lib/grape/endpoint.rb:172:in `call!'
  grape (0.9.0) lib/grape/endpoint.rb:160:in `call'
  rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in `block in call'
  rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:in `block in recognize'
  rack-mount (0.8.3) lib/rack/mount/code_generation.rb:68:in `optimized_each'
  rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:in `recognize'
  rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in `call'
  grape (0.9.0) lib/grape/api.rb:128:in `call'
  grape (0.9.0) lib/grape/api.rb:43:in `call!'
  grape (0.9.0) lib/grape/api.rb:39:in `call'
  actionpack (4.2.0.beta2) lib/action_dispatch/routing/mapper.rb:50:in `serve'
  actionpack (4.2.0.beta2) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  actionpack (4.2.0.beta2) lib/action_dispatch/journey/router.rb:30:in `each'
  actionpack (4.2.0.beta2) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.0.beta2) lib/action_dispatch/routing/route_set.rb:750:in `call'
  rack (1.6.0.beta) lib/rack/etag.rb:23:in `call'
  rack (1.6.0.beta) lib/rack/conditionalget.rb:25:in `call'
  rack (1.6.0.beta) lib/rack/head.rb:13:in `call'
  actionpack (4.2.0.beta2) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.2.0.beta2) lib/action_dispatch/middleware/flash.rb:257:in `call'
  rack (1.6.0.beta) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.6.0.beta) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.2.0.beta2) lib/action_dispatch/middleware/cookies.rb:558:in `call'
  activerecord (4.2.0.beta2) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.2.0.beta2) lib/active_record/connection_adapters/abstract/connection_pool.rb:645:in `call'
  activerecord (4.2.0.beta2) lib/active_record/migration.rb:378:in `call'
  actionpack (4.2.0.beta2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.2.0.beta2) lib/active_support/callbacks.rb:83:in `run_callbacks'
  actionpack (4.2.0.beta2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.2.0.beta2) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.2.0.beta2) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  actionpack (4.2.0.beta2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.2.0.beta2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.0.beta2) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.0.beta2) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.0.beta2) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.0.beta2) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.0.beta2) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.0.beta2) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.0.beta2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.0.beta) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.0.beta) lib/rack/runtime.rb:17:in `call'
  activesupport (4.2.0.beta2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.0.beta) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.0.beta2) lib/action_dispatch/middleware/static.rb:103:in `call'
  rack (1.6.0.beta) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.0.beta2) lib/rails/engine.rb:514:in `call'
  railties (4.2.0.beta2) lib/rails/application.rb:161:in `call'
  rack (1.6.0.beta) lib/rack/tempfile_reaper.rb:15:in `call'
  rack (1.6.0.beta) lib/rack/lint.rb:49:in `_call'
  rack (1.6.0.beta) lib/rack/lint.rb:37:in `call'
  rack (1.6.0.beta) lib/rack/showexceptions.rb:24:in `call'
  rack (1.6.0.beta) lib/rack/commonlogger.rb:33:in `call'
  rack (1.6.0.beta) lib/rack/chunked.rb:54:in `call'
  rack (1.6.0.beta) lib/rack/content_length.rb:15:in `call'
  rack (1.6.0.beta) lib/rack/handler/webrick.rb:89:in `service'

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