Last active
July 22, 2020 21:47
-
-
Save dsazup/93015f25194a928f2378c9587b12dfbb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= @user_assignments.each do |assignment| %> | |
assignment.steps.size -- will do query for each assignment | |
It would be nice to do something like | |
@user_assignments.preload_counts(:steps) and then just do assignment.steps_count | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Assignment < ApplicationRecord | |
belongs_to :course | |
belongs_to :user | |
has_many :steps, through: :course | |
end | |
class Course < ApplicationRecord | |
belongs_to :course | |
has_many :steps | |
end | |
class Step < ApplicationRecord | |
belongs_to :course | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment