Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update generator guide [ci skip] #30343

Merged
merged 1 commit into from
Aug 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions guides/source/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ $ bin/rails generate generator initializer
create lib/generators/initializer/initializer_generator.rb
create lib/generators/initializer/USAGE
create lib/generators/initializer/templates
invoke test_unit
create test/lib/generators/initializer_generator_test.rb
```

This is the generator just created:

```ruby
class InitializerGenerator < Rails::Generators::NamedBase
source_root File.expand_path("templates", __dir__)
source_root File.expand_path('templates', __dir__)
end
```

Expand All @@ -122,7 +124,7 @@ And now let's change the generator to copy this template when invoked:

```ruby
class InitializerGenerator < Rails::Generators::NamedBase
source_root File.expand_path("templates", __dir__)
source_root File.expand_path('templates', __dir__)

def copy_initializer_file
copy_file "initializer.rb", "config/initializers/#{file_name}.rb"
Expand Down Expand Up @@ -241,6 +243,8 @@ $ bin/rails generate generator rails/my_helper
create lib/generators/rails/my_helper/my_helper_generator.rb
create lib/generators/rails/my_helper/USAGE
create lib/generators/rails/my_helper/templates
invoke test_unit
create test/lib/generators/rails/my_helper_generator_test.rb
```

After that, we can delete both the `templates` directory and the `source_root`
Expand Down Expand Up @@ -510,13 +514,13 @@ Available options are:
Any additional options passed to this method are put on the end of the line:

```ruby
gem "devise", git: "git://github.com/plataformatec/devise", branch: "master"
gem "devise", git: "https://github.com/plataformatec/devise.git", branch: "master"
```

The above code will put the following line into `Gemfile`:

```ruby
gem "devise", git: "git://github.com/plataformatec/devise", branch: "master"
gem "devise", git: "https://github.com/plataformatec/devise.git", branch: "master"
```

### `gem_group`
Expand Down