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

SomeModel.where(id: value) fails #223

Closed
dkolath opened this issue Apr 3, 2014 · 4 comments
Closed

SomeModel.where(id: value) fails #223

dkolath opened this issue Apr 3, 2014 · 4 comments

Comments

@dkolath
Copy link

dkolath commented Apr 3, 2014

I can execute the following:

SomeModel.find(1)

When I try to execute the same search using where, it fails.

SomeModel.where(id: 1).first

RESULT:

TypeError: no implicit conversion of Array into Hash
from /Users/dkolath/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/her-0.6.8/lib/her/model/relation.rb:15:in `merge'

I have a search form that allows a user to search by any combination of fields including id, and have to workaround this issue by checking the form parameters and explicitly issuing a Model.find if it's an ID search.

@remi
Copy link
Owner

remi commented Jun 9, 2014

Can you print what HTTP request is sent to the API with the find code and with the where code?

@joyrows
Copy link

joyrows commented Jan 14, 2015

Model.find(143921207)

Started GET "/v1/models/143921207" for 127.0.0.1 at 2015-01-14 12:03:50 -0500
Processing by V1::ModelsController#show as */*
  Parameters: {"id"=>"143921207"}
  Model Load (1.6ms)  SELECT  "models".* FROM "models"  WHERE "models"."id" = 143921207 LIMIT 1
  Rendered v1/models/_model.json.jbuilder (7.3ms)
  Rendered v1/models/show.json.jbuilder (12.2ms)
Completed 200 OK in 20ms (Views: 17.6ms | ActiveRecord: 1.6ms)

###################################################################################

Model.where(id: 143921207).first

Started GET "/v1/models/143921207?id=143921207" for 127.0.0.1 at 2015-01-14 12:05:48 -0500
Processing by V1::ModelsController#show as */*
  Parameters: {"id"=>"143921207"}
  Model Load (0.5ms)  SELECT  "models".* FROM "models"  WHERE "models"."id" = 143921207 LIMIT 1
  Rendered v1/models/_model.json.jbuilder (1.2ms)
  Rendered v1/models/show.json.jbuilder (2.8ms)
Completed 200 OK in 8ms (Views: 6.3ms | ActiveRecord: 0.5ms)

We also set our controller to ignore the extra id parameter from where, and we get the same "TypeError: no implicit conversion of Array into Hash"

@maticompiano
Copy link

Hi! Same problem here. Any idea?

@zacharywelch
Copy link
Collaborator

looks like this was fixed by #437. Thanks!

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

5 participants