1
0
Fork 0
find-us-lunch/app/controllers/friendships_controller.rb

55 lines
1.1 KiB
Ruby
Raw Normal View History

2014-10-15 13:32:35 -04:00
class FriendshipsController < ApplicationController
2014-10-15 13:50:58 -04:00
before_action :require_login
2014-10-15 13:32:35 -04:00
before_action :set_friendship, only: [:show, :destroy]
def index
@friendships = Friendship.all
end
def show
end
def new
@friendship = Friendship.new
end
def create
@friendship = Friendship.new(friendship_params)
respond_to do |format|
if @friendship.save
format.html {
redirect_to @friendship,
notice: 'Friendship was successfully created.'
}
format.json { render :show, status: :created, location: @friendship }
else
format.html { render :new }
format.json {
render json: @friendship.errors, status: :unprocessable_entity
}
end
end
end
def destroy
@friendship.destroy
respond_to do |format|
format.html {
redirect_to friendships_url,
notice: 'Friendship was successfully destroyed.'
}
format.json { head :no_content }
end
end
private
def set_friendship
@friendship = Friendship.find(params[:id])
end
def friendship_params
params[:friendship]
end
end