[Rails] Re: no sql in the controller guideline

2009-05-06 Thread PP Junty
thanks for the tips Phlip, specially the How easily can you test your SQL-like statement? metric. Phlip wrote: Nothing that looks at all like SQL should go into a controller, view, or helper. Helpers are a gray area. In software design, there is the concept of breaking up low-level coupling

[Rails] Re: no sql in the controller guideline

2009-05-06 Thread Julian Leviston
On 06/05/2009, at 12:37 PM, Phlip phlip2...@gmail.com wrote: Phlip wrote: Nothing that looks at all like SQL should go into a controller, view, or helper. Things that look like SQL include any kind of query more elaborate than a simple accessor call. I just read _all_ of

[Rails] Re: no sql in the controller guideline

2009-05-05 Thread Tyler MacDonald
PP Junty rails-mailing-l...@andreas-s.net wrote: Nothing that looks at all like SQL should go into a controller, view, or helper. it really came as a surprise to me as Rails itself seems to go against such practice by its AR 'conditions' option, which most of the times contains SQL code.

[Rails] Re: no sql in the controller guideline

2009-05-05 Thread Charles Johnson
Like all good programming rules of thumb there are interesting exceptions. Complicated unions and intersections, especially where the from clause might be a dynamic select, such as might be needed for a report can be very difficult to do without resorting to passing the sql directly to the

[Rails] Re: no sql in the controller guideline

2009-05-05 Thread PP Junty
Charles Johnson wrote: Like all good programming rules of thumb there are interesting exceptions. this is exactly where things get confused, because code like the example i provided seems to be the norm, not the exception. -- Posted via http://www.ruby-forum.com/.

[Rails] Re: no sql in the controller guideline

2009-05-05 Thread Frederick Cheung
On May 5, 11:52 pm, PP Junty rails-mailing-l...@andreas-s.net wrote: Charles Johnson wrote: Like all good programming rules of thumb there are interesting exceptions. this is exactly where things get confused, because code like the example i provided seems to be the norm, not the

[Rails] Re: no sql in the controller guideline

2009-05-05 Thread PP Junty
The code you posted is fine, it just depends where you put it: that is why i named the thread no sql in the controller. :) - in a view: super bad - in the controller: not so good i agree, i just didn't see any mention to this guideline in the books i consulted or in the AR source code

[Rails] Re: no sql in the controller guideline

2009-05-05 Thread Phlip
PP Junty wrote: hello. i just checked Chad Fowler's post 20 Rails Development No-No's and one guideline caught my attention. it says: Nothing that looks at all like SQL should go into a controller, view, or helper. Things that look like SQL include any kind of query more elaborate than a

[Rails] Re: no sql in the controller guideline

2009-05-05 Thread Phlip
Phlip wrote: Nothing that looks at all like SQL should go into a controller, view, or helper. Things that look like SQL include any kind of query more elaborate than a simple accessor call. I just read _all_ of Fowler's statement. Helpers are a gray area. In software design, there is