I have split one of my larger projects up into mountable rails engines and I want to find a method that checks if a rails engine is mounted. As an example I have a User class in my main app
user.rb
class User < ApplicationRecord
has_many :searches, as: :searchable, class_name: MySearchEngine::Search
end
I would like to wrap this has_many association as well as other code for the integration of the engine in an if statement so that it only adds the code if MySearchEngine has been mounted
You should be able to check whether they are available by defined? MySearchEngine::Search
defined? MySearchEngine::Search
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.