1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

Merge pull request #398 from crossb0w/ar-generator-includes-column-name

added custom-name to generator to avoid uninitialized constant error
This commit is contained in:
Anil Kumar Maurya 2016-09-21 15:46:24 +05:30 committed by GitHub
commit a7d7f7cf29
2 changed files with 6 additions and 1 deletions

View file

@ -12,7 +12,7 @@ module ActiveRecord
def copy_aasm_migration
if model_exists?
migration_template "migration_existing.rb", "db/migrate/add_aasm_state_to_#{table_name}.rb"
migration_template "migration_existing.rb", "db/migrate/add_#{column_name}_to_#{table_name}.rb"
else
migration_template "migration.rb", "db/migrate/aasm_create_#{table_name}.rb"
end

View file

@ -36,4 +36,9 @@ describe ActiveRecord::Generators::AASMGenerator, type: :generator do
assert_migration "db/migrate/add_aasm_state_to_jobs.rb"
end
it "add custom aasm_column in existing model" do
run_generator %w(job state)
assert_migration "db/migrate/add_state_to_jobs.rb"
end
end