Skip to content

Commit a3c29b7

Browse files
author
Francesco Rodriguez
committed
use :only instead of :except callback option in the controller template
As [Security Guide](http://edgeguides.rubyonrails.org/security.html#whitelists-versus-blacklists) says, it's better to use `before_filter only: []` instead of `except: []` so we don't forget to turn the filter off for newly added actions.
1 parent 69163cc commit a3c29b7

File tree

1 file changed

+2
-3
lines changed
  • railties/lib/rails/generators/rails/scaffold_controller/templates

1 file changed

+2
-3
lines changed

railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<% end -%>
55
<% module_namespacing do -%>
66
class <%= controller_class_name %>Controller < ApplicationController
7-
before_action :set_<%= singular_table_name %>, except: [ :index, :new, :create ]
8-
7+
before_action :set_<%= singular_table_name %>, only: [ :show, :edit, :update, :destroy ]
8+
99
# GET <%= route_url %>
1010
# GET <%= route_url %>.json
1111
def index
@@ -82,7 +82,6 @@ def destroy
8282
end
8383
end
8484

85-
8685
private
8786
# Use callbacks to share common setup or constraints between actions.
8887
def set_<%= singular_table_name %>

0 commit comments

Comments
 (0)