Kim
Kim

Reputation: 2156

Perform search on instance object

I have the following code:

  @anatomy = Anatomy.find_by_sql(" some long sql here")

I want to perform a search on the @anatomy resultset.

I tried the code below but it does not seem to work.

@anatomy_subset = @anatomy.find :first, :conditions => ["public_id = ?", public_id ]

It is giving me:

wrong number of arguments (2 for 1)

How do I search for something on the @anatomy instance object?

Thank a lot for your help.

Upvotes: 1

Views: 53

Answers (1)

forker
forker

Reputation: 2679

You can't make SQL search out of SQL server, do this instead:

subset = @anatomy.select { |entity| entity.public_id == public_id }

Upvotes: 1

Related Questions