4 ms·
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
by spohlenz 14y 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.
- ericb 14y agoExtracting 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.