top | item 5198808

(no title)

spohlenz | 13 years ago

A before_filter is just a method that runs before an action - there's no requirement for it to set an instance variable or redirect. In Rails 4, this method has been aliased as before_action to make this clearer.

Since the behavior of this method doesn't have too much to do with showing a topic, I think it makes sense. Extracting it also makes it possible to move it up to the ApplicationController for wider use.

discuss

order

ericb|13 years ago

Extracting it into a separate method is what makes it available for wider use--not the before_filter.

That said, you provide a justification--the topicality of the code itself to the idea of "show." It is a decent point that I missed in the article. I'll have to think on that.

I question this logic living in the controller at all, though. It looks like a model logic that should, from the controller perspective, look like current_user.review_for_promotion.