notebook/app/controllers/application_controller.rb
2012-12-24 06:49:42 -06:00

21 lines
529 B
Ruby

class ApplicationController < ActionController::Base
protect_from_forgery
def is_logged_in?
session[:user]
end
def redirect_if_not_logged_in
unless is_logged_in?
redirect_to login_path, :notice => "You must be logged in to do that!"
end
end
def require_ownership_of_character
character = Character.find(params[:id])
unless session[:user] and session[:user] == character.user.id
redirect_to character_list_path, :notice => "You don't have permission to do that!"
end
end
end