Re: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses

2008-08-18 Thread Matt Wynne
Thanks for the reminder. This stuff is in a protected admin area so I don't really care, but I should play on the safe side anyhow. cheers, Matt http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily ref

Re: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses

2008-08-18 Thread Mark Wilden
On Mon, Aug 18, 2008 at 1:26 PM, Matt Wynne <[EMAIL PROTECTED]> wrote: > def get_where_clause > >clause = [] > >clause << "city_id = [EMAIL PROTECTED]" if @city_id >clause << "name like '[EMAIL PROTECTED]'" if @name > I think you've still got SQL injection problems he

Re: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses

2008-08-18 Thread Matt Wynne
Thanks Scott. I refactored it today to use what I called a QueryAdapter, namespaced inside the model. It basically subclasses Hash, takes the params from the controller into the constructor, and becomes the hash to be sent to find_all. I feels much better, as I now have the code that's coup

Re: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses

2008-08-15 Thread Scott Taylor
On Aug 15, 2008, at 9:29 AM, David Chelimsky wrote: On Aug 15, 2008, at 6:46 AM, Matt Wynne <[EMAIL PROTECTED]> wrote: On 15 Aug 2008, at 12:25, David Chelimsky wrote: Hey Matt - welcome! The paginate() method lives on the model class, so there's nothing stopping you from wrapping those ca

Re: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses

2008-08-15 Thread David Chelimsky
On Aug 15, 2008, at 6:46 AM, Matt Wynne <[EMAIL PROTECTED]> wrote: On 15 Aug 2008, at 12:25, David Chelimsky wrote: Hey Matt - welcome! The paginate() method lives on the model class, so there's nothing stopping you from wrapping those calls in methods on the model, slinging around the params

Re: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses

2008-08-15 Thread Matt Wynne
On 15 Aug 2008, at 12:25, David Chelimsky wrote: Hey Matt - welcome! The paginate() method lives on the model class, so there's nothing stopping you from wrapping those calls in methods on the model, slinging around the params object. # CityController def get_cities City.paginate_all(params

Re: [rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses

2008-08-15 Thread David Chelimsky
On Fri, Aug 15, 2008 at 5:28 AM, Matt Wynne <[EMAIL PROTECTED]> wrote: > Hi TDD Fans, > I'm pretty new to Ruby / RSpec / Rails but not to TDD. > This is more of a general 'how do you do good design in a rails app' > question than an rspec-specific question. I'm asking it here because I know > this

[rspec-users] Proper Encapsulation of SQL WHERE / ORDER BY Clauses

2008-08-15 Thread Matt Wynne
Hi TDD Fans, I'm pretty new to Ruby / RSpec / Rails but not to TDD. This is more of a general 'how do you do good design in a rails app' question than an rspec-specific question. I'm asking it here because I know this list is read by lots of people who care about good design, but please fe