Add basic invitations
This commit is contained in:
33
app/controllers/invitations_controller.rb
Normal file
33
app/controllers/invitations_controller.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
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
|
||||
Reference in New Issue
Block a user