File tree 2 files changed +3
-3
lines changed
2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change 56
56
add_callback :call_node , at : 'start' do |node |
57
57
if node . receiver . nil? && %i[ belongs_to has_one has_many has_and_belongs_to_many ] . include? ( node . name )
58
58
association_name = node . arguments . arguments . first . to_value
59
- option_elements = node . arguments . arguments . second &.elements
60
59
options = { }
61
- if option_elements
60
+ if node . arguments . arguments . length > 1 && node . arguments . arguments . last . is_a? ( Prism ::KeywordHashNode )
61
+ option_elements = node . arguments . arguments . last . elements
62
62
%i[ foreign_key foreign_type polymorphic ] . each do |option_key |
63
63
option_element = option_elements . find { |element | element . key . value == option_key . to_s }
64
64
options [ option_key ] = option_element . value . to_value if option_element
Original file line number Diff line number Diff line change 22
22
rails_tables . each do |table_name , table_info |
23
23
belongs_to_associations = rails_models [ :associations ] . select do |association |
24
24
# find all belongs_to associations
25
- association [ :class_name ] . tableize == table_name || association [ :type ] == 'belongs_to'
25
+ association [ :class_name ] . tableize == table_name && association [ :type ] == 'belongs_to'
26
26
end
27
27
polymorphic_belongs_to_associations = belongs_to_associations . select do |association |
28
28
next false unless association [ :polymorphic ]
You can’t perform that action at this time.
0 commit comments