[rspec-users] [rails] An authorization question

Stephen Eley sfeley at gmail.com
Tue Mar 3 01:34:21 EST 2009

On Tue, Mar 3, 2009 at 1:04 AM, Mark Wilden <mark at mwilden.com> wrote:
> On Mon, Mar 2, 2009 at 8:35 PM, Stephen Eley <sfeley at gmail.com> wrote:
>>  @invoices = Invoice.by_role(user)
> It doesn't seem right to me that invoices know about users and roles.
> I would try something like
>  user.role.invoices

Heh.  Which is what Zach said he wanted to do, and it isn't wrong.
But it doesn't seem right to *me* that roles know about invoices.
>8->  As I see it, if you go that path you end up having to inform
roles about every *other* model, and consolidating all your business
logic in one class.  At which point you're risking drifting away from
object-oriented programming and heading back to big procedures and
spaghetti code.

But that's a kneejerk response, and it needn't be that bad.  It really
comes down to taste.  To-mae-to, to-mah-to.  Sooner or later it's all
ones and zeros.

Have Fun,
   Steve Eley (sfeley at gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine

More information about the rspec-users mailing list