34 lines
911 B
Ruby
34 lines
911 B
Ruby
class InvitationsController < ApplicationController
|
|
before_action :require_user_signed_in
|
|
|
|
# GET /invitations
|
|
def index
|
|
@invitations = current_user.invitations
|
|
end
|
|
|
|
# POST /invitations
|
|
def create
|
|
@invitation = Invitation.new(user: current_user)
|
|
|
|
respond_to do |format|
|
|
if @invitation.save
|
|
format.html { redirect_to @invitation, notice: 'Invitation was successfully created.' }
|
|
format.json { render :show, status: :created, location: @invitation }
|
|
else
|
|
format.html { render :new }
|
|
format.json { render json: @invitation.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# DELETE /invitations/1
|
|
def destroy
|
|
@invitation = current_user.invitations.find(params[:id])
|
|
@invitation.destroy
|
|
respond_to do |format|
|
|
format.html { redirect_to invitations_url }
|
|
format.json { head :no_content }
|
|
end
|
|
end
|
|
end
|