@infused Does that mean it would be redundant to create a `make_id` column for `Car`?
– MontiJun 19 '15 at 18:07
2
No, it would not work without a make_id. The first query `Car.find_by(make: chevy)` simply gets converted to `Car.find_by(make_id: chevy.id)` under the hood.
– infusedJun 19 '15 at 18:09
@ArupRakshit The linked question asks whether to use find, find_by or where. The accepted answer is virtually identical to infused's comments. I don't think a question has to be a word-for-word facsimile to be considered a duplicate when it covers the exact same material and comes to the same conclusions.
– MarsAtomicJun 19 '15 at 18:24
@nmonti You can either. As you have `make` attribute on the model, so Rails will definer _setter_ and _getter_ for you. Thus your _first version_ will work perfectly as your second version..
– Arup RakshitJun 19 '15 at 18:29
@ArupRakshit Even if I knew nothing, I can look at that supposedly totally different question and answer this one because the underlying mechanism is the same, but that's me. I don't see how you think "The both end up using the same exact SQL" is different from "Use whichever one you feel suits your needs best," but that's you. People see things differently.
– MarsAtomicJun 19 '15 at 18:39
@MarsAtomic It is not the same at all. I've actually used that link before when I didn't know the difference between `find_by` and `where`. It mentions nothing about the underlying SQL, which is what I wanted to know in this question.
– MontiJun 19 '15 at 19:15
@nmonti Please re-read the question. The OP actually specifically mentions that the underlying SQL is the same.
– MarsAtomicJun 19 '15 at 20:11