kasperite
kasperite

Reputation: 2478

Rails Active Resources ignore conditions

I have been searching a solution for this issue but in no vain. Basically, I am trying to do some searches using Active Resources eg:

File.find(:all, :params => {:file_name => "blah"})

or:

File.find(:all, :conditions => {:file_name => "blah"})

File is an Active Resource object

I expect the result to be filtered but the output is the same as File.find(:all)(conditions are completely ignored). Has anyone experienced a similar problem?I am using rails 3.0.7, this code is called from a web app which is talking to another API server using AR.

Any suggestions will be much appreciated

Thanks

Upvotes: 1

Views: 274

Answers (2)

Krista
Krista

Reputation: 915

I have the same type of setup, and tons of searching in my application where large results need to get filtered - however, I have been accomplishing this using the API Server side.

So calls would look like:

File.find(:all, :params => {:file_name => "blah"})

Which would be translated into some search URL by rails:

http://someip:port/someurl/files/?file_name=blah

So the API would receive this with the file_name parameter and filter the result set based on that search, and then return those filtered results to the rails server.

I hope that at least helps in some way :)

Upvotes: 0

Alexandre Abreu
Alexandre Abreu

Reputation: 1417

Dont know if i got your point. I think this should do:

File.where file_name: "blah"

Upvotes: 1

Related Questions