-
Notifications
You must be signed in to change notification settings - Fork 329
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
nested scaffold for has_many through #696
Comments
Please, post the parameters of the request |
|
I will try to reproduce it. I think ActivScaffold will use a code like this: Account.find(178).survey_answers.includes(:survey_questions).order('"survey_answers"."created_at" DESC, survey_questions.question ASC, "survey_answers"."id" ASC') Does that code use the right query? |
no, because it is not including the survey_questions table in the query as a join, but rather includes:
|
I see the query from the log has a condition for created_at. How did you do it? Did you override beginning_of_chain in your controller? You should call super because is the method which will load associated records with account_id |
I am not 100% sure what is adding that condition. I don't have beginning_of_chain overridden here, but there must be some other way that results were being filtered to the past 3 months. I looked briefly but the only thing I could find was a field_search.default_params, but I tried commenting that out and it was still including those conditions in the query. |
Scenario:
This works ok for getting all survey answers that belong to an account, with account.survey_answers returning the correct data, however when I add this relation to a scaffold in order to render the survey answers scaffold inline, AS ends up generating a query that does not include the intermediate table (survey_results) in the join, and does not contain the condition checking that survey_results.account_id = X.
The actual query is something like this (survey_questions is a column in the survey_answers scaffold, so it is preloading that information):
This causes all survey answers to be shown instead of those for the account itself. Is there any way to force it to include the intermediate table in the join and include the correct where conditions?
Thanks!
The text was updated successfully, but these errors were encountered: