Skip to content

Commit

Permalink
tableize object_name
Browse files Browse the repository at this point in the history
  • Loading branch information
flyerhzm committed Mar 16, 2021
1 parent 33f4b3e commit d714f2c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rails/convert_active_record_dirty_5_0_to_5_1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def call_after_create
object_attributes = {}
within_file 'db/schema.rb' do
within_node type: 'block', caller: { type: 'send', message: 'create_table' } do
object_name = node.caller.arguments.first.to_value.singularize
object_name = node.caller.arguments.first.to_value.tableize
object_attributes[object_name] = []
with_node type: 'send', receiver: 't', message: { not: 'index' } do
unless node.arguments.empty?
Expand All @@ -170,7 +170,7 @@ def call_after_create

within_files 'app/{models,observers}/**/*.rb' do
within_node type: 'class' do
object_name = node.name.to_source.underscore
object_name = node.name.to_source.underscore.gsub(/\//, '_').tableize

find_callbacks_and_convert(BEFORE_CALLBACK_NAMES, BEFORE_CALLBACK_CHANGES, object_attributes[object_name])
find_callbacks_and_convert(AFTER_CALLBACK_NAMES, AFTER_CALLBACK_CHANGES, object_attributes[object_name])
Expand Down

0 comments on commit d714f2c

Please sign in to comment.