Sha256: 11f0ac4b73e19526b189e37cadbe45d89d73f0cbb1fa078b9b92414b239aa163
Contents?: true
Size: 869 Bytes
Versions: 6
Compression:
Stored size: 869 Bytes
Contents
# Allow the metal piece to run in isolation require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails) # note: we're not returning 404 in the usuaul sense - it actually just tells rails to continue metal chain class CreateAdminUser def self.call(env) if env["PATH_INFO"] =~ /^\/users/ or @admin_defined or not User.table_exists? @status = [404, {"Content-Type" => "text/html"}, "Not Found"] else @admin_defined = User.first(:include => :roles, :conditions => ["roles.name = 'admin'"]) @status = [404, {"Content-Type" => "text/html"}, "Not Found"] if @admin_defined end # redirect to user creation screen return @status || [302, {'Location'=> '/users/new' }, []] ensure # Release the connections back to the pool. ActiveRecord::Base.clear_active_connections! end end
Version data entries
6 entries across 6 versions & 2 rubygems