Reputation: 19
I am overriding the Devise:RegistrationController and i need to add a before filter authentication function which is in the BaseController of my app how to add that before filter . i am facing this problem as i extended the Devise:RegistrationsController and unable to extend the basecontroller
Upvotes: 0
Views: 34
Reputation: 6455
Create a concern, then include that concern in both controllers:
## app/controllers/concerns/concern_with_the_method_i_want.rb
module ConcernWithTheMethodIWant
def method
return 'This is the method'
end
end
class BaseController < ApplicationController
include ConcernWIthTheMethodIWant
end
class RegistrationController < Devise::RegistrationController
include ConcernWithTheMethodIWant
end
This will let you do:
BaseController.new.method
=> 'This is the method'
Devise:RegistrationController.new.method
=> 'This is the method'
Upvotes: 1