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

Commit 5e1ef02

Browse files
committed
Fix rsvp flow for unauthenticated users
1 parent e512523 commit 5e1ef02

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

app/controllers/events_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ def create
1616

1717
def show
1818
@event = Event.where(id: params[:id]).includes(responses: [ :user ]).first
19-
@response = @event.response_for(current_user).presence || Response.new
19+
@response = @event.response_for(current_user).presence || Response.new rescue nil
20+
end
21+
22+
def responses
23+
redirect_to event_path(params[:id])
2024
end
2125

2226
protected

app/views/events/show.html.haml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
- if resp.additional_guests > 0
2828
%span.label.label-danger +#{ resp.additional_guests }
2929
- if resp.comments.present?
30-
%p= resp.comments
30+
%p= markdownify(resp.comments)
3131

3232
.col-md-3
3333
%ul.nav
34-
- if current_user.attending?(@event)
34+
- if current_user? && current_user.attending?(@event)
3535
%li= link_to "I can't go", event_response_path(@event, @response), class: "btn btn-danger", method: :delete
3636
%li
3737
= form_for @response, url: event_response_path(@event, @response) do |f|

config/routes.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99

1010
resources :events do
1111
resources :responses, only: [ :create, :update, :destroy ]
12-
end
1312

13+
member do
14+
get :responses
15+
end
16+
end
1417

1518
get '/dashboard', to: 'dashboard#index', as: 'dashboard'
1619

0 commit comments

Comments
 (0)