diff options
author | Jan Bernacki <releu@me.com> | 2012-08-22 14:50:41 +0400 |
---|---|---|
committer | Jan Bernacki <releu@me.com> | 2012-09-06 23:34:10 +0400 |
commit | d965bbfe9f45be8d203a85482923253c751a20bd (patch) | |
tree | 79263e71bde4866946ed8899a10a1db9061b4b51 /activerecord/lib/rails | |
parent | e8c9f0513da0fac45ba585cf62739da57603f4ed (diff) | |
download | rails-d965bbfe9f45be8d203a85482923253c751a20bd.tar.gz rails-d965bbfe9f45be8d203a85482923253c751a20bd.tar.bz2 rails-d965bbfe9f45be8d203a85482923253c751a20bd.zip |
add mini-validator on creating migration
move validation to AR
Diffstat (limited to 'activerecord/lib/rails')
-rw-r--r-- | activerecord/lib/rails/generators/active_record/migration/migration_generator.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb b/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb index f6a432c6e5..a3c274d9b9 100644 --- a/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb +++ b/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb @@ -7,6 +7,7 @@ module ActiveRecord def create_migration_file set_local_assigns! + validate_file_name! migration_template "migration.rb", "db/migrate/#{file_name}.rb" end @@ -41,6 +42,14 @@ module ActiveRecord attribute.name.singularize.foreign_key end.to_sym end + + private + + def validate_file_name! + unless file_name =~ /^[_a-z0-9]+$/ + raise IllegalMigrationNameError.new(file_name) + end + end end end end |