Closed conj40 closed 4 years ago
Totally. I always refer folks to this when I’m talking about n+1 queries. https://semaphoreci.com/blog/2017/08/09/faster-rails-eliminating-n-plus-one-queries.html Basically, if you watch your rails console when you visit this page, you’ll see multiple queries. If you “eager load” the association ahead of time, rails will only make one query, which is faster (especially if there are a lot of log entries per table). So you might do something like. @nursery_table = NurseryTable.includes(:restoration_activity_log_entry).where(id: params[id])
That might not be the exact syntax, but should get you started. Lmk if I can offer more hints!
On Aug 18, 2019, at 7:32 AM, chub93 notifications@github.com wrote:
@chub93 commented on this pull request.
In rails/app/views/nursery_tables/show.html.erb:
+
- Recent restoration activities: +
+
Date Performed Cleaned? Percent full Bleached Dead - <% @nursery_table.restoration_activity_log_entries.order('id DESC').each do |entry| %> Hi @LizPrescott would it be possible to give me an example please?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
History of restoration table feature added for #63
Description
Useful table feature added to nursery_tables/show.html.erb . This table displays a most-recent-first history of restoration activities for the Nursery Table.
Type of change
How Has This Been Tested?
Tested on my local machine everything works fine.
Screenshots
before![Screenshot 2019-08-17 at 17 04 12](https://user-images.githubusercontent.com/51298718/63214528-1ad0b100-c111-11e9-98e0-0cf2aafdea22.png)
after![Screenshot 2019-08-17 at 16 47 21](https://user-images.githubusercontent.com/51298718/63214325-e0feab00-c10e-11e9-9059-8654cbfca83d.png)