2008/9/26 David Chelimsky <[EMAIL PROTECTED]> > On Fri, Sep 26, 2008 at 12:18 PM, Mark Wilden <[EMAIL PROTECTED]> wrote: > > On Fri, Sep 26, 2008 at 9:47 AM, Ashley Moran > > <[EMAIL PROTECTED]> wrote: > > > > To me, spec'ing attributes is a red flag. It is not always a bad thing > or wrong, but it suggests that the focus is on structure instead of > behaviour
What David said. A lot. It seems these conversations come up time and again because Rails overloads the idea of "model". In a Rails app the model serves as both your domain model and your persistence strategy, because of the coupling inherent in the Active Record pattern. Your domain model should evolve out of solving problems in your domain. For any non-trivial domain model the persistence strategy should be an entirely separate concern. At the risk of going off on one, Active Record scales to *exactly zero behaviour* in your model. In other words it is perfect for data-on-the-screen apps, which to be fair is about 90% of web apps. As soon as your domain model becomes sufficiently interesting it becomes a contest between us and the AR pixies. Luckily we have the likes of David and Pat Maddox on our side :) If you start by specifying what you want your application to do in the form of a single user example (a scenario), the model should fall out of solving this. Unfortunately this doesn't fit the model-driven (generators) approach that Rails encourages. I'm not sure what advice to offer here, other than to be aware that Rails "best practices" are usually counter to an outside-in, behaviour-driven approach to writing applications. So if you want to use all the code-gen magic in Rails you will always be making these trade-offs. Cheers, Dan
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users