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

Slowest Lab Submission #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def show
@user = User.find(params[:id])
if signed_in?
@following = current_user.outward_follows.where(
:followed_id => @user.id).exists?
:followed_id => @user.id).exists?.includes(:attendances, :shows, :venues)
end
end

Expand Down
3 changes: 2 additions & 1 deletion app/models/attendance.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class Attendance < ActiveRecord::Base
belongs_to :user
belongs_to :show
belongs_to :show, -> { includes :venue}


validates_uniqueness_of :user_id, :scope => [:show_id]
end
1 change: 1 addition & 0 deletions app/models/show.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Show < ActiveRecord::Base
belongs_to :user
belongs_to :venue
has_many :attendances
has_many :users, :through => :attendances
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class User < ActiveRecord::Base
has_many :followers, :through => :inward_follows, :source => :follower
has_many :followeds, :through => :outward_follows, :source => :followed

has_many :attendances
has_many :attendances, -> {includes :show}

def avatar
a = read_attribute(:avatar)
Expand Down
1 change: 1 addition & 0 deletions app/models/venue.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
class Venue < ActiveRecord::Base
belongs_to :user
has_many :shows
end