ActiveRecord::AutoWritable

test

Automatically switch to writable role on ActiverRecord writable methods.

Installation

Add this line to your application's Gemfile:

gem 'active_record-auto_writable'

And then execute:

bundle install

Or install it yourself as:

gem install active_record-auto_writable

Usage

Just install and it works.

Configuration

By default, it wraps all ActiveRecord write methods by ActiveRecord::Base.conneted_to(role: :writing) { ... }. If you want to modify this behavior, set a custom Proc to ActiveRecord::AutoWritable.configuration.proxy.

ActiveRecord::AutoWritable.configuration.proxy = lambda do |&block|
  AnimalRecord.connected_to(role: :zoo_keeper, &block)
end