On Nov 22, 2014, at 5:03 PM, Sunny Juneja jr.su...@gmail.com wrote:
Hey everyone,
I've obviously done a bad job of explaining this :). Let me try to elaborate.
Suppose I've ran xyz = Model.where(attribute: true)
A SQL query is created and executed. The results are saved to xyz as an
Hey everyone,
I've obviously done a bad job of explaining this :). Let me try to
elaborate.
Suppose I've ran xyz = Model.where(attribute: true)
A SQL query is created and executed. The results are saved to xyz as an
ActiveRecord_Relation. The query looks something like this:
SELECT models.*
On Nov 14, 2014, at 4:05 PM, Sunny Juneja jr.su...@gmail.com wrote:
Hey, I ran into this problem fairly recently. I needed to get a large number
of records and search them over and over again on different attributes. I
found myself writing code that looked a lot like this.
records =
Hey, I ran into this problem fairly recently. I needed to get a large
number of records and search them over and over again on different
attributes. I found myself writing code that looked a lot like this.
records = Model.where(...)
records.select { |r| r.attribute1 == attribute1 r.attribute2
You should be able to use find_by and pass in a hash with attributes and
respective values to find a record.
Please take a look at the docs for find_by on the api guides.
Carlos Antonio da Silva - via celular
On Nov 14, 2014 7:44 PM, Sunny Juneja jr.su...@gmail.com wrote:
Hey, I ran into this