-
Notifications
You must be signed in to change notification settings - Fork 1
How to integrate Bali with Rails?
Bali is designed from the start to be able to load configuration from multiple files, so you are okay to call Bali.map_rules
for as many times as you want.
Therefore, it makes it possible to define rules for specific target in a different file. This kind of configuration is preferable in Rails situation.
To do so, first things first, let us create a folder named rules
under app
directory. This is where all your rules will be defined. You can define bank_account_rules.rb
, submerchant_rules.rb
and so on.
Afterward, create an initializer file under config/initializerz
folder, let's call it bali.rb
. The file should minimally contain these codes:
Dir[Rails.root.join('app', 'rules', '*.rb')].each do |file|
require file
end
You could also store common Bali configuration in this file, for example, to define that if given instance of User
, Bali should extract the roles by calling it roles
function. This is optional.
Bali.map_rules do
roles_for 'User', :roles
end
You are set!