Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with entity in :using #75

Closed
amrnt opened this issue Nov 21, 2011 · 11 comments
Closed

Problem with entity in :using #75

amrnt opened this issue Nov 21, 2011 · 11 comments

Comments

@amrnt
Copy link

amrnt commented Nov 21, 2011

Assume I have 2 models: User and Preference. User has_one preference.

And here's Grape entities:

module Entities
  class PreferenceEntity < Grape::Entity
    expose :logo, :background_color
  end

  class UserEntity < Grape::Entity
    expose :full_name
    expose :email
    expose :preference, :as => :preferences, :using => PreferenceEntity
  end
end

Now, with

get "me" do
  present current_user, :with => Entities::UserEntity
end

Throws this error:

{
error: "wrong number of arguments(0 for 2)",
backtrace: [
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/entity.rb:145:in `autoload'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/entity.rb:145:in `value_for'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/entity.rb:124:in `block in serializable_hash'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/entity.rb:123:in `each'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/entity.rb:123:in `inject'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/entity.rb:123:in `serializable_hash'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/activesupport-3.1.1/lib/active_support/json/encoding.rb:55:in `block in as_json'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/activesupport-3.1.1/lib/active_support/json/encoding.rb:78:in `check_for_circular_references'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/activesupport-3.1.1/lib/active_support/json/encoding.rb:54:in `as_json'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/activesupport-3.1.1/lib/active_support/json/encoding.rb:245:in `block in as_json'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/activesupport-3.1.1/lib/active_support/json/encoding.rb:245:in `each'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/activesupport-3.1.1/lib/active_support/json/encoding.rb:245:in `map'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/activesupport-3.1.1/lib/active_support/json/encoding.rb:245:in `as_json'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/activesupport-3.1.1/lib/active_support/json/encoding.rb:47:in `block in encode'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/activesupport-3.1.1/lib/active_support/json/encoding.rb:78:in `check_for_circular_references'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/activesupport-3.1.1/lib/active_support/json/encoding.rb:46:in `encode'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/activesupport-3.1.1/lib/active_support/json/encoding.rb:31:in `encode'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/activesupport-3.1.1/lib/active_support/core_ext/object/to_json.rb:20:in `to_json'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/multi_json-1.0.3/lib/multi_json/engines/json_gem.rb:17:in `encode'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/multi_json-1.0.3/lib/multi_json.rb:72:in `encode'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/base.rb:115:in `encode_json'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/formatter.rb:79:in `call'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/formatter.rb:79:in `block in after'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/formatter.rb:78:in `collect'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/formatter.rb:78:in `after'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/base.rb:26:in `call!'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/base.rb:19:in `call'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/base.rb:25:in `call!'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/base.rb:19:in `call'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/base.rb:25:in `call!'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/base.rb:19:in `call'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/error.rb:44:in `block in call!'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/error.rb:43:in `catch'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/error.rb:43:in `call!'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/middleware/base.rb:19:in `call'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:152:in `block in call'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in `block in recognize'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:68:in `optimized_each'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:95:in `recognize'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:141:in `call'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bundler/gems/grape-ece183048418/lib/grape/api.rb:32:in `call'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/warden-1.1.0/lib/warden/manager.rb:35:in `block in call'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/warden-1.1.0/lib/warden/manager.rb:34:in `catch'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/warden-1.1.0/lib/warden/manager.rb:34:in `call'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:195:in `context'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:190:in `call'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/rack-1.3.5/lib/rack/reloader.rb:44:in `call'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/thin-1.3.1/lib/thin/connection.rb:80:in `block in pre_process'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/thin-1.3.1/lib/thin/connection.rb:78:in `catch'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/thin-1.3.1/lib/thin/connection.rb:78:in `pre_process'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/thin-1.3.1/lib/thin/connection.rb:53:in `process'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/thin-1.3.1/lib/thin/connection.rb:38:in `receive_data'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:179:in `run_machine'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/eventmachine-1.0.0.beta.4/lib/eventmachine.rb:179:in `run'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/thin-1.3.1/lib/thin/backends/base.rb:61:in `start'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/thin-1.3.1/lib/thin/server.rb:159:in `start'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/thin-1.3.1/lib/thin/controllers/controller.rb:86:in `start'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/thin-1.3.1/lib/thin/runner.rb:185:in `run_command'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/thin-1.3.1/lib/thin/runner.rb:151:in `run!'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/gems/thin-1.3.1/bin/thin:6:in `<top (required)>'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bin/thin:19:in `load'",
"/Users/amr/.rvm/gems/ruby-1.9.2-p290@api-new/bin/thin:19:in `<main>'"
]
}
@amrnt
Copy link
Author

amrnt commented Dec 8, 2011

I got over this issue by using

expose :preferences do |model, options|
  if model.preference
    # Hash
  end
end

instead of expose :preference, :as => :preferences, :using => PreferenceEntity

But I think its still an issue!

@justfalter
Copy link

I believe I've run into this issue, myself. I can't seem to find a way leverage :using in the way that the documentation seems to intend its usage: nesting entities.

Grape::Entity implements #as_json, but when JSON encoders like OkJson go to encode the nested Entity objects, it tries to call #to_json (which does not exist). Depending on the JSON encoder, they may chose to encode an object that lacks #to_json, however OkJson throws an exception if it does not.

I've effectively done the following in my code in order to encode the entities in a consistent manner.

expose :preferences do |model, options|
  if model.preference
    model.preference.map { |pref| PreferenceEntity.new(pref).serializable_hash }
  end
end

Alternatively, doing something like the following also works, but I suspect that it is a bit inappropriate.

class PreferenceEntity < Grape::Entity
   alias :to_json :as_json
   ...
end

I haven't looked into it more deeply, but I may see if I can't figure out a patch and send a pull request to fix it.

@256dpi
Copy link

256dpi commented Aug 28, 2012

For me the :using property is also not working. I think its because of the missing to_json function or something like that:

[
  {
    ...
    "slots": [
      "#<Harbour::API::V1::SlotEntity:0x007fcb33d243c0>",
      "#<Harbour::API::V1::SlotEntity:0x007fcb33d24230>",
      "#<Harbour::API::V1::SlotEntity:0x007fcb33d240f0>",
      "#<Harbour::API::V1::SlotEntity:0x007fcb33d23fb0>",
      "#<Harbour::API::V1::SlotEntity:0x007fcb33d23dd0>"
    ]
  }
]

To fix the nesting problem i'm using currently the following method:

expose :slots do |station,options|
  station.slots.map{ |slot| SlotEntity.new(slot).serializable_hash }
end

@chrisbloom7
Copy link

Similar fix for a has_one relationship:

expose :address do |model, options|
  if model.address
    API::Entities::V1::Location.new(model.address).serializable_hash
  end
end

Trying it the recommended way resulted in the following error:

undefined method `represent' for #<Class:0x00000129261f90>

/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.8/lib/active_record/dynamic_matchers.rb:50:in `method_missing'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/entity.rb:348:in `value_for'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/entity.rb:317:in `block in serializable_hash'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/entity.rb:315:in `each'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/entity.rb:315:in `inject'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/entity.rb:315:in `serializable_hash'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/base.rb:122:in `serialize'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/base.rb:134:in `encode_json'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/formatter.rb:79:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/formatter.rb:79:in `block in after'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/formatter.rb:78:in `collect'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/formatter.rb:78:in `after'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/base.rb:27:in `call!'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/base.rb:20:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/base.rb:26:in `call!'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/base.rb:20:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/base.rb:26:in `call!'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/base.rb:20:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/error.rb:44:in `block in call!'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/error.rb:43:in `catch'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/error.rb:43:in `call!'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/middleware/base.rb:20:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/head.rb:9:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb:134:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/endpoint.rb:113:in `call!'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/endpoint.rb:103:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:152:in `block in call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in `block in recognize'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in `optimized_each'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:95:in `recognize'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:141:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/api.rb:425:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/api.rb:55:in `call!'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/grape-0.2.2/lib/grape/api.rb:51:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:600:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/warden-1.2.1/lib/warden/manager.rb:34:in `catch'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/warden-1.2.1/lib/warden/manager.rb:34:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/etag.rb:23:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/conditionalget.rb:25:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/middleware/head.rb:14:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/middleware/flash.rb:242:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/middleware/cookies.rb:339:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.8/lib/active_record/query_cache.rb:64:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `_run__644697953361164916__call__1047081581030344329__callbacks'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/middleware/reloader.rb:65:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/rack/logger.rb:26:in `call_app'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/rack/logger.rb:16:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/engine.rb:479:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/application.rb:223:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/rack/log_tailer.rb:17:in `call'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/thin-1.5.0/lib/thin/connection.rb:81:in `block in pre_process'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/thin-1.5.0/lib/thin/connection.rb:79:in `catch'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/thin-1.5.0/lib/thin/connection.rb:79:in `pre_process'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/thin-1.5.0/lib/thin/connection.rb:54:in `process'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/thin-1.5.0/lib/thin/connection.rb:39:in `receive_data'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/thin-1.5.0/lib/thin/backends/base.rb:63:in `start'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/thin-1.5.0/lib/thin/server.rb:159:in `start'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/handler/thin.rb:13:in `run'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/server.rb:265:in `start'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands/server.rb:70:in `start'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands.rb:55:in `block in <top (required)>'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
/Users/chrisbloom7/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'

@lucassus
Copy link

I have the same issue. The strangest thing is that it works on my laptop but breaks on travis-ci (https://travis-ci.org/lucassus/mongo_browser/jobs/3839962) and on my other machine.
Here is code for my API: https://github.com/lucassus/mongo_browser/blob/master/lib/mongo_browser/api.rb
And here is my workaround for the problem: lucassus/mongo_browser@47de199

On both machines I have the same ruby's configuration: ruby-1.9.3-p327-perf with separate rvm gemsets for my project.

@dblock
Copy link
Member

dblock commented Jan 5, 2013

This may be fixed on HEAD. We now fully reply on the formatter, so if you use format :json it will call to_json where possible. I'd appreciate if those on this thread could try again and see if there're still problems.

@dblock
Copy link
Member

dblock commented Feb 9, 2013

@agileanimal Does this bug belong in grape-entity?

@idyll
Copy link
Contributor

idyll commented Feb 12, 2013

What's the best way to move it over and keep the thread?

@mtjhax
Copy link

mtjhax commented Mar 12, 2013

I was not able to reproduce the original error from @amrnt in Rails 3.2.11 and Grape 0.2.6. I notice the original error backtrace referenced Rails 3.1.1 and Grape 0.2.2. Unclear if I am attempting to reproduce the problem improperly or it was fixed per @dblock.

@dblock
Copy link
Member

dblock commented Mar 7, 2014

@amrnt Do you have any updates to this? Is it a problem still? Can I close this?

@dblock
Copy link
Member

dblock commented Nov 21, 2014

I am closing this.

@dblock dblock closed this as completed Nov 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants