application_controller.rb revision 8441cc0be003fcd6294a1b5b93e1143b5bb82cea
76b43e4417bab52e913da39b5f5bc2a130d3f149Timo Sirainenclass ApplicationController < ActionController::Base
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # CanCan Authorization
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen rescue_from CanCan::AccessDenied do |exception|
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen redirect_to root_url, :alert => exception.message
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # A foreign key constraint exception from the database
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # shorten the message
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen :flash => {:error => "Whatever you tried to do - the server is unable to process your request because of a foreign key constraint. (#{message})" }
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # anything else
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen flash[:error] = "you need admin privileges for this action"