ActiveGenerator
ActiveGenerator extends the base rails generators with commonly used generators.
Installation
Add this line to your application's Gemfile:
gem 'active_generator'
And then execute:
$ bundle
Or install it yourself as:
$ gem install active_generator
Table of Contents
Configuration
rails generate active_generator:install
will generate the following file:
../config/initalizers/active_generator.rb
ActiveGenerator::Settings.configure do |config|
config.autoload_controller_generator_locale = true
config.autoload_helper_generator_locale = true
config.autoload_job_generator_locale = true
config.autoload_mailer_generator_locale = true
config.autoload_model_generator_locale = true
config.autoload_service_generator_locale = true
config.autoload_task_generator_locale = true
config.autoload_view_generator_locale = true
config.test_framework = 'test_unit'
end
Environment
Generates an environment file in the config/environments
directory.
Options:
- environment: development, test, production
rails generate environment staging production
will generate the following staging.rb
file:
# config/environments/staging.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
~~~~~~~~~~~~~~~~~~ OMITED IN README ~~~~~~~~~~~~~~~~~~
end
Initializer
Generates an initializer file in the config/initializers
directory.
rails generate initializer stripe
will generate the following stripe.rb
file:
# config/initializers/stripe.rb
# TODO:
# Add initializer code here.
Locale
Generates an initializer file in the config/locales
directory.
Generators:
- api
- controller
- helper
- job
- mailer
- model
- service
- task
- uploader
- view
Options:
- language: 2, 4, 6, and 6 character prefix
rails generate locale:controller admin/user en-GB
will generate the following user.yml
file:
# config/locales/en-GB/controller/admin/user.yml
#==================================================
# Table of Contents
#==================================================
# V1
# Test
# Actions
# Methods
en-GB:
controllers:
v1:
test:
# Actions
#--------------------------------------------------
actions:
todo: "TODO"
# Methods
#--------------------------------------------------
methods:
todo: "TODO"
Service
Generates an service file in the app/services
directory.
rails generate service social/twitter
will generate the following twitter.rb
file:
# app/services/social/twitter.rb
class Social::Twitter
# TODO:
# Add service code here.
end
View
Generates an view file in the app/views
directory.
rails generate view social/twitter index
will generate the following index.html.erb
file:
# app/views/social/twitter/index.html.erb
<!-- TODO: -->
<!-- Add view code here. -->
Contributing
Your contribution is welcome.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request