module PowerTools module ActionController # HTTP Error pages def not_found render :file => "#{RAILS_ROOT}/public/404.html", :status => 404 and return false end def not_authorised render :file => "#{RAILS_ROOT}/public/403.html", :status => 403 and return false end def find_or_404(context, id, field=nil, options={}) field ||= :id options[:conditions] ||= {} options[:conditions][field] = id context.find(:first, options) or not_found end # override this to taste def ssl_on? false end def require_ssl if ssl_on? unless request.ssl? redirect_to :protocol => 'https://', :host => request.host return false end request.env['HTTPS'] = 'on' end end end end ActionController::Base.class_eval do include PowerTools::ActionController include PowerTools::ActionController::ParamTypes include PowerTools::ActionController::Resources end