Thanks for the feedback.
I think what I'm ultimately trying to do is legit though, so I want to
try and make the case one more time.
So what I want is to be able to say something in a controller like:
with the result that all find calls on a Story model from that
controller will only return stories that belong to the current account,
and any new stories will always be associated with the current account.
I've done this. It's easy to whip up using with_scope and around
filters, and it seems like a clean and useful abstraction to me. Among
other things, it reduces the risk that a hole in test coverage and/or a
missing find condition could result in, say, returning stories for the
wrong account. You can nest scoping and do this for several models at a
time too, no problem.
This works great for finds. The trouble is that you can't do the same
thing for creates, because the association won't be set if you call save
instead of create, which is too fragile. But, the abstraction makes the
most sense if it works in both directions.
It seems like the legit uses of with_scope that folks have mentioned all
involve passing :find, and the bad uses I've given all use :create.
Documentation would help, but the bigger issue is consistency. I think
either with_scope/:create should treat new records the same way the rest
of ActiveRecord does, or it should go away. Perhaps the way to make it
go away would be to leave with_scope public, but extract the part that
handles the :create hash to a private method.
Thanks, and I hope I'm not ranting too much here -- I'm just interested
in seeing this little corner of Rails be less surprising.