|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
class AsciicastsController < ApplicationController
|
|
|
|
|
PER_PAGE = 20
|
|
|
|
|
|
|
|
|
|
before_filter :load_resource, :only => [:show, :destroy]
|
|
|
|
|
before_filter :ensure_authenticated!, :only => [:destroy]
|
|
|
|
|
|
|
|
|
|
respond_to :html, :json
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
@ -11,8 +14,28 @@ class AsciicastsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def show
|
|
|
|
|
@asciicast = Asciicast.find(params[:id])
|
|
|
|
|
respond_with @asciicast
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
|
if @asciicast.user == current_user && @asciicast.destroy
|
|
|
|
|
redirect_to profile_path(current_user),
|
|
|
|
|
:notice => 'Your asciicast was deleted.'
|
|
|
|
|
else
|
|
|
|
|
if current_user
|
|
|
|
|
target = profile_path(current_user)
|
|
|
|
|
else
|
|
|
|
|
target = root_path
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
redirect_to target,
|
|
|
|
|
:alert => "Oops, we couldn't remove this asciicast. Sorry."
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def load_resource
|
|
|
|
|
@asciicast = Asciicast.find(params[:id])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|