Extensions to Thor for working within Rails environments
Simplify Thor commands that rely on Rails components
Add this line to your application's Gemfile:
gem 'thor-rails'
And then execute:
$ bundle
Or install it yourself as:
$ gem install thor-rails
Include Thor::Rails into your Thor command and the Rails application will automatically be booted when your action is invoked.
NOTE: The environment loaded can be controlled via the standard RAILS_ENV
environmental variable.
require 'thor/rails'
class MyCommand < Thor
include Thor::Rails
desc 'do_something', 'do some work'
def do_something
# Rails environment is loaded and available!
say ::Rails.env
end
end
Patches are always welcome and thank you to all project contributors!
Interested in contributing? Review the project contribution guidelines and get started!