Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 33 lines (28 sloc) 0.896 kb
c81b544 @polarina Stuff
authored
1 class InvitationsController < ApplicationController
2 respond_to :html
3
4 def create
5 @invitation = Invitation.new params[:invitation]
803383c @polarina Messages (issue #2)
authored
6 @invitation.user = current_user
c81b544 @polarina Stuff
authored
7
8 if @invitation.save
9 respond_to do |format|
803383c @polarina Messages (issue #2)
authored
10 format.html { redirect_to invitations_path }
c81b544 @polarina Stuff
authored
11 end
12 else
13 respond_to do |format|
803383c @polarina Messages (issue #2)
authored
14 @invitations = Invitation.where(:user_id => current_user.id)
15 @invitees = current_user.invitees
c81b544 @polarina Stuff
authored
16 format.html { render :action => "index" }
17 end
18 end
19 end
20
21 def index
22 @invitation = Invitation.new
2d921e1 @polarina Sort invitations. Fixes #109
authored
23 @invitees = current_user.invitees.order{created_at.desc}
24 @invitations = Invitation.where(:user_id => current_user.id).order{created_at.desc}
25 respond_with @invitations
c81b544 @polarina Stuff
authored
26 end
27
28 def destroy
803383c @polarina Messages (issue #2)
authored
29 Invitation.where(:user_id => current_user.id, :key => params[:id]).destroy_all
30 redirect_to invitations_path
c81b544 @polarina Stuff
authored
31 end
32 end
Something went wrong with that request. Please try again.