2010/2/3 Nicolás Sanguinetti <[email protected]>: > On Wed, Feb 3, 2010 at 2:07 PM, <[email protected]> wrote: >> I absolutely love the idea of encapsulated the daisy chained calls >> (c_u.comp.project) into a controller methods so all i gotta do is stub that >> out. > > Oooh, I hate that one :) > > You're adding lots of small methods that actually don't define how the > class should behave, IMO. > In fact, how a client or project is related to a user is a > responsibility of the models, not the controllers. > > I would much rather turn > > @client = current_user.company.clients.find(params[:project][:client_id]) > @project = @client.projects.build(params[:project]) > > into > > @client = current_user.find_client(params[:project][:client_id]) > @project = @client.projects.new(params[:project]) > > And add the helper method on the models.
I strongly agree. Extracting the methods to the controller is merely an intermediate step. If the methods belong on other objects, then that tends to become clear soon enough. -- J. B. (Joe) Rainsberger :: http://www.jbrains.ca :: http://blog.thecodewhisperer.com Diaspar Software Services :: http://www.diasparsoftware.com Author, JUnit Recipes 2005 Gordon Pask Award for contribution to Agile practice :: Agile 2010: Learn. Practice. Explore. _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
