diff options
author | Scott Bronson <brons_github@rinspin.com> | 2013-01-25 20:27:33 -0800 |
---|---|---|
committer | Scott Bronson <brons_github@rinspin.com> | 2013-01-25 20:27:33 -0800 |
commit | 21e4113e9d7ffa869c405c047ec2fa9fac11e8a1 (patch) | |
tree | e6525797ab32c6263312958b9df02d5bf3e9f4a8 /railties | |
parent | 9df25844ba77f5ebdfe6178c78c63de53c15c45c (diff) | |
download | rails-21e4113e9d7ffa869c405c047ec2fa9fac11e8a1.tar.gz rails-21e4113e9d7ffa869c405c047ec2fa9fac11e8a1.tar.bz2 rails-21e4113e9d7ffa869c405c047ec2fa9fac11e8a1.zip |
avoid using alias in generators
Ruby's alias produces public methods, causing a spurious Thor task
to be created. For example, this is the reason MigrationGenerator
currently has two tasks:
> ActiveRecord::Generators::MigrationGenerator.all_tasks.keys
=> ["singular_name", "create_migration_file"]
singular_name was meant to be an attribute, not a task. Because it's
public, it gets called as a task every time the generator is invoked.
The fix is to ensure all generator methods have the correct
visibility.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/generators/named_base.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 9965db98de..8f5118c3b0 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -28,7 +28,10 @@ module Rails protected attr_reader :file_name - alias :singular_name :file_name + + def singular_name + file_name + end # Wrap block with namespace of current application # if namespace exists and is not skipped |