You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
asciinema.org/app/controllers/asciicasts_controller.rb

42 lines
897 B
Ruby

13 years ago
class AsciicastsController < ApplicationController
PER_PAGE = 20
before_filter :load_resource, :only => [:show, :destroy]
before_filter :ensure_authenticated!, :only => [:destroy]
respond_to :html, :json
13 years ago
def index
@asciicasts = Asciicast.
order("created_at DESC").
page(params[:page]).
per(PER_PAGE)
end
def show
respond_with @asciicast
13 years ago
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
13 years ago
end