LiveRamp/jack

:through associations are created but do not work

Opened this issue · 1 comments

an association such as
class Student
has_many :classes, :through => :student_class
end

creates the association to Class in the Student java class, however it's treated like a regular has_many (i.e. Class is expected to have Student's ids as a foreign key)

@qstearns saw a related issue.

The process_model method is supposed to ignore associations with through keyword.

In parse_associations :

if not_matches
    matching_lines = matching_lines.reject { |l| l =~ /^\s*#{not_matches}/ }
end

The regex looks incorrect. It specifies: start of line + zero or any number of space + the not_matches string, which is often not true because there could be some characters other than space before the not_matches token.

In the through case, it should be ignored, as written in models_dir_processor.rb, however:

# Association
#   has_many :some_models, :through => :intermediate_model
["  has_many :some_models, :through => :intermediate_model"].reject{|l| l =~ /^\s*#{":through"}/}
=> [" has_many :some_models, :through => :intermediate_model"]

I don't think we want to fix this anytime soon. It will affect massive existing code. A workaround is to add :jack_generate => false for now.