On 1 June 2010 14:21, Michael Pavling <[email protected]> wrote:
> On 1 June 2010 14:03, Colin Law <[email protected]> wrote:
>> Michael
>> To some extent I agree with Tom here, ideally it should be possible to
>> get straight to the answer without going through the sql.  The
>> condition is that the number of authors for the book should be greater
>> than 5 and
>> that published should be true, so the requirement is fully defined,
>> the question is how to tell active record that that is what is
>> required.  To some extent the framework has failed (or one is just
>> trying to do something too complex for it) if one has to work out the
>> sql first then work out how to tell ActiveRecord to generate that sql.
>
> Colin, I doubt that you or I would *need* to do the SQL first for our
> own models; but I often do so anyway before writing a complex finder
> as a safety-net to ensure Rails returns what I want. But if the OP
> makes up an example that doesn't match his models, then we can't post
> solutions. If he has no idea what the SQL needs to be to return data
> from his database, then maybe there's some more non-Rails learning to
> cover.
>...
>
> But unless the OP can be *sure* the results are correct for his
> implementation (by checking it against a SQL DB query) then it strikes
> me as a little bit of a worry.

Playing devil's advocate again, I disagree, if one understands
ActiveRecord syntax fully and one codes up a find, then one *can* be
sure that it is correct.  It should not be necessary to check that the
SQL is correct as one is then suggesting that ActiveRecord has made a
mistake.  There may be other reasons to check the sql of course,
efficiency worries for example.

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to