Stop returning false from your before filters
Published almost 4 years ago
In the past version of Rails you had to explicitly return false from before filters to halt the filter chain and make sure the action doesn’t get run. The code looked somewhat like :
class AdminController < ApplicationController before_filter :check_admin private def check_admin unless current_user.admin? redirect_to home_path return false end end end
But since Rails 2.0, If you call render, head or redirect_to from a before_filter, the filter chain will be halted. So the above controller will now look like :
class AdminController < ApplicationController before_filter :check_admin private def check_admin redirect_to home_path unless current_user.admin? end end
You should go ahead and update all your before filters to reflect this change. return false is nothing but code smell.