Behold, a before_filter
:
class ThingController < ApplicationController
before_filter :check_stuff, :if => proc {Rails.env.production?}
end
<
i have done this on my code while ago. I hope that example helps to you. If you can use if statement but that should point to another method like I did here.
class Admin::ArticlesController < ApplicationController
before_filter :deny_access, :unless => :draft_and_admin?
def show
@article = Article.find(params[:id])
end
protected
def draft_and_admin?
Article.find(params[:id]).draft? && current_user.admin?
end
end