class ArgumentsController < ApplicationController
before_filter :login_required
def create
@argument = Argument.create!(params[:argument])
flash[:notice] = 'You have now argued your case'
respond_to do |format|
format.html
format.js
end
end
def show
@argument = Argument.find(params[:id])
respond_to do |format|
format.html
format.js
end
end
def destroy
@argument = Argument.find(params[:id])
if is_creator?
@argument.destroy
flash[:notice] = 'Your argument has been removed'
respond_to do |format|
format.html { redirect_to :back }
format.js
end
else
flash[:notice] = 'That\'s not your own argument you\'re trying to delete fool'
redirect_to :back
end
end
protected
#Check is user is allowed to edit and update options of this debate.
def is_creator?
if argument_creator?
true
else
false
end
end
end
Bookmarks