Skip to content

Commit

Permalink
added custom-name to generator to avoid uninitialized constant error
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastian Wegge committed Sep 19, 2016
1 parent fc8b5ef commit 673b6f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/generators/active_record/aasm_generator.rb
Expand Up @@ -12,7 +12,7 @@ class AASMGenerator < ActiveRecord::Generators::Base

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
Expand Down
5 changes: 5 additions & 0 deletions spec/generators/active_record_generator_spec.rb
Expand Up @@ -36,4 +36,9 @@
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

0 comments on commit 673b6f7

Please sign in to comment.