Skip to content

Commit

Permalink
Always raise 404 when resource not found
Browse files Browse the repository at this point in the history
  • Loading branch information
wicz committed Mar 26, 2012
1 parent e129ef6 commit 08865ca
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions app/controllers/application_controller.rb
Expand Up @@ -6,12 +6,7 @@ class ApplicationController < ActionController::Base
helper_method :current_person, :signed_in?, :login_path, :clubhouse_person

def current_person
begin
@current_person ||= clubhouse_person(session[:person_github_nickname])
rescue Clubhouse::Client::PersonNotFound

end
@current_person
@current_person ||= clubhouse_person(session[:person_github_nickname])
end

def signed_in?
Expand All @@ -34,16 +29,20 @@ def login_path
Rails.env.production? ? '/auth/github' : '/auth/developer'
end

protected

def not_found
raise ActionController::RoutingError.new('Not Found')
end

def find_course
@course = Course.find(params[:course_id] || params[:id])
course_id = params[:course_id] || params[:id]
@course = Course.find(course_id)
rescue ActiveRecord::RecordNotFound
redirect_to(root_url, alert: "Couldn't find course")
not_found
end

private

def clubhouse_person(github_nickname)
PersonDecorator.from_github(github_nickname)
end

end

0 comments on commit 08865ca

Please sign in to comment.