Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:through associations are created but do not work #26

Open
vshulman opened this issue Jul 25, 2011 · 1 comment
Open

:through associations are created but do not work #26

vshulman opened this issue Jul 25, 2011 · 1 comment

Comments

@vshulman
Copy link

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)

@tuliren
Copy link
Contributor

tuliren commented Dec 28, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants