Reputation: 19723
In the controller:
before_action { |controller| controller.param_policy(action_name) }
.
Also in the same controller is the param_policy
method. Under private
. Why is rails complaining with:
private method `param_policy' called for #<SomeController:0x007fc80196bc40>
The code:
class SomeController < ApplicationController
before_action { |controller| controller.param_policy(action_name) }
private
def param_policy(action_name)
# ...
end
end
Is before_action
outside the scope of private
methods?
Upvotes: 1
Views: 2344
Reputation: 6398
The correct syntax in rails 4 to append a callback to a controller is:
before_action :param_policy
In rails 3, it was before_filter
. Seeing the error, it seems that you are calling param_policy
on an instance of class SomeController
, which cannot call the private method, as it is a basic OOPS concept.
Upvotes: 3