Provides a detailed view of the underlying schema that backs an ActiveRecord model.
This functionality can be added to any object that implements ActiveRecord's columns interface.
Add this line to your application's Gemfile:
gem 'model_probe'
And then execute:
$ bundle
Or install it yourself as:
$ gem install model_probe
MyModel.extend ModelProbe
MyModel.probe
MyModel.print_fixture
MyModel.print_model
Create config/initializers/model_probe.rb
ActiveRecord::Base.extend ModelProbe if Rails.env.development?
Create lib/tasks/model.rake
namespace :model do
desc <<~DESC
Print model. Usage: `rails model:probe[User]`
DESC
task :probe, [:klass] => :environment do |task, args|
klass = args.klass
puts klass.constantize.print_model
end
end