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

with_rich_text_#{name} eager loading does not work #18

Closed
sedubois opened this issue Jan 10, 2022 · 5 comments · Fixed by #24
Closed

with_rich_text_#{name} eager loading does not work #18

sedubois opened this issue Jan 10, 2022 · 5 comments · Fixed by #24

Comments

@sedubois
Copy link
Owner

This test currently does not pass:

test 'post content is eager loaded' do
post = assert_queries(2) { Post.with_rich_text_content.last }
assert_no_queries do
assert_equal 'Hello world!', post.content.to_plain_text
skip('FIXME: this should execute no queries')
end
end

Creating this issue for visibility, in case someone would be willing to investigate and offer a PR.

@doits
Copy link
Contributor

doits commented Feb 23, 2022

Just found out you can do Post.includes(:rich_text_translations) to eager load all translations, so this could maybe be used by .with_all_rich_text?

Not sure how to eager load one specific rich text attribute with this though.

@sedubois
Copy link
Owner Author

sedubois commented Feb 26, 2022

That's good to know @doits, would you feel like submitting a PR (with test) for implementing with_all_rich_text?

@doits
Copy link
Contributor

doits commented Feb 26, 2022

Sure, gave it a try in #23.

@sedubois sedubois changed the title with_rich_text eager loading does not seem to work with_rich_text_#{name} eager loading does not work Feb 27, 2022
@sedubois
Copy link
Owner Author

Thanks @doits! with_all_rich_text is now fixed by #23. with_rich_text_#{name} still needs fixing.

doits added a commit to doits/mobility-actiontext that referenced this issue Feb 27, 2022
@doits
Copy link
Contributor

doits commented Feb 27, 2022

@sedubois see #24 for a possible fix.

sedubois pushed a commit that referenced this issue Feb 28, 2022
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

Successfully merging a pull request may close this issue.

2 participants