Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.

Commit

Permalink
Cut out a couple SELECTs
Browse files Browse the repository at this point in the history
  • Loading branch information
philtr committed Feb 6, 2014
1 parent dcb9d9e commit 1b963cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def attending
responses.count + responses.sum(:additional_guests)
end

def created_by?(user)
created_by == user.id
end

def response_for(user)
responses.where(user_id: user.id).first
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/events/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
.col-sm-2.col-xs-4
.thumbnail
= image_tag resp.user.gravatar, style: "width: 100%"
- if @event.creator == resp.user
- if @event.created_by?(resp.user)
%span.label.label-default Organizer
.caption
%b
Expand All @@ -34,7 +34,7 @@

.col-md-3
%ul.nav.nav-stacked
- if @event.creator == current_user
- if @event.created_by?(current_user)
%li= link_to "Edit this Event", edit_event_path(@event), class: "btn btn-warning"
- if current_user? && current_user.attending?(@event)
%li= link_to "Bow out gracefully", event_response_path(@event, @response), class: "btn btn-danger", method: :delete
Expand Down

0 comments on commit 1b963cc

Please sign in to comment.