Permalink
This commit does not belong to any branch on this respository, and may belong to a fork outside of the repository.
Showing
with
33 additions
and 1 deletion.
@@ -0,0 +1,30 @@ | ||
class TicketsController < ApplicationController | ||
before_action :signed_in_user | ||
|
||
def create | ||
@ticket = current_user.ticket.build(ticket_params) | ||
if @ticket.save | ||
flash[:success] = "Ticket Posted!" | ||
redirect_to root_url | ||
else | ||
@feed_items = [] | ||
render 'static_pages/home' | ||
end | ||
end | ||
|
||
def destroy | ||
@ticket.destroy | ||
redirect_to root_url | ||
end | ||
|
||
private | ||
|
||
def ticket_params | ||
params.require(:ticket).permit() | ||
end | ||
def correct_user | ||
@ticket = current_user.tickets.find_by(id: params[:id]) | ||
redirect_to root_url if @ticket.nil? | ||
end | ||
|
||
end |