This post originated from an RSS feed registered with Ruby Buzz
by Obie Fernandez.
Original Post: That about sums it up
Feed Title: Obie On Rails (Has It Been 9 Years Already?)
Feed URL: http://jroller.com/obie/feed/entries/rss
Feed Description: Obie Fernandez talks about life as a technologist, mostly as ramblings about software development and consulting. Nowadays it's pretty much all about Ruby and Ruby on Rails.
> I think it's a poor choice to limit something that people find useful just
> because it doesn't fit your idea of useful. Why not let the coder make these
> decisions?
You must be new here :). Rails is opinionated software. We make things
that we consider good style easy to do and bad style hard. Or rather,
we make good style beautiful and bad style ugly. So even though
with_scope is going protected, you can still use it in filters if you
really, really want to. Just use send(:with_scope) -- that'll side-step
the access control. Yes, that'll be ugly and it's intended to be.
Using around_filters in the manor you describe makes it really hard to
figure out what's going on from looking at the action in isolation. It
looks like you're doing a straight, in-secure find to the naked eye.
And there's no bread crumbs for others to follow that'll leave them to
your around_filter. It's a recipe for hard-to-read code. And it shields
the reader from understand your model hierarchy.
In summary, Rails will shake its head at you for using with_scope in
filters, but will ultimately leave it at your discretion to choose the
right path. We believe in encouragement and discouragement, not
allowing or forbidding.