Stop returning false from your before filters
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 :
1 2 3 4 5 6 7 8 9 10 11 12 |
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 :
1 2 3 4 5 6 7 8 9 |
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.
Images:


Recent comments
20 weeks 4 days ago
20 weeks 5 days ago
22 weeks 4 days ago
24 weeks 6 days ago
39 weeks 4 days ago
42 weeks 4 days ago
43 weeks 2 days ago
43 weeks 2 days ago
43 weeks 4 days ago
45 weeks 6 days ago