sensae
sensae

Reputation: 493

Ruby on Rails complaining "Unknown key params"

I'm trying to call find with the :params key, using a method call that looks like this:

Product.find(:all, :params => { :name => "Test" })

Error:

ArgumentError: Unknown key(s): params

Calling Product.find(:all) works just fine, but when I try to pass anything in with the :params key it throws an error.

Upvotes: 0

Views: 1729

Answers (3)

bor1s
bor1s

Reputation: 4113

Try to use :conditions => { ... } instead

Upvotes: 1

Jits
Jits

Reputation: 9748

If you are using Rails 3.x try:

Product.where(:name => "Test")

If Rails 2.x try:

Product.find(:all, :conditions => { :name => "Test" })

Upvotes: 6

Gazler
Gazler

Reputation: 84190

Product.where(:name => "Test" )

I have never seen a find with a nested hash of parameters. The key should map to your field in the database.

Upvotes: 0

Related Questions