This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.active_record.observers = :'payment/user_customer_observer' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveRecord::Base.observers.disable :all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Payment | |
class UserCustomerObserver < ActiveRecord::Observer | |
observe User::Customer | |
attr_reader :customer | |
def after_update(customer) | |
customer.update!(payments: customer.payments + 1) | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :generate_engine do | |
# Get name sent from console | |
name = ENV['name'].downcase | |
# Store useful paths | |
engine_path = "engines/#{name}" | |
dummy_path = 'spec/dummy' | |
lib_files_path = 'lib/tasks/files' | |
dummy_relative_path = "#{engine_path}/#{dummy_path}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dir.glob(File.expand_path('../engines/*', __FILE__)).each do |path| | |
engine = File.basename(path) | |
gem engine, path: "engines/#{engine}", require: (ENV['ENGINE'].nil? || ENV['ENGINE'] == engine) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dir.glob(File.expand_path('../engines/*', __dir__)).each do |path| | |
engine = File.basename(path) | |
mount engine.classify.constantize::Engine, at: '/' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initializer :append_migrations do |app| | |
unless app.root.to_s.match? root.to_s | |
config.paths['db/migrate'].expanded.each do |expanded_path| | |
app.config.paths['db/migrate'] << expanded_path | |
end | |
end | |
end |