Reputation: 329
I have a rails engine I'd like to make more universal. I have before_action :authenticate_user! in my controllers for devise.
Is there a way I can put if devise gem exists put before_action :authenticate_user! otherwise leave out.
Upvotes: 1
Views: 121
Reputation: 38092
Use defined?
to look for Devise
:
before_filter :authenticate_user!, if: -> { defined?(Devise) }
Upvotes: 2