Class: DatabasesController

Inherits:
OnboardingController show all
Defined in:
lib/ecrire/onboarding/controllers/databases_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #signed_in?, #url

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ecrire/onboarding/controllers/databases_controller.rb', line 7

def create
  info ||= {
    'adapter' => 'postgresql',
    'database' => database,
    'user' => user,
    'password' => password,
    'encoding' => 'utf8'
  }
  begin
    ActiveRecord::Base.configurations = {
      'development' => info,
      'test' => info,
      'production' => info
    }
    ActiveRecord::Base.establish_connection
    ActiveRecord::Base.connection
    migrate!
  rescue Exception => e
    @exception = e
    ActiveRecord::Base.clear_all_connections!
    render 'index' and return
  end

  redirect_to '/users'
end

#indexObject



5
# File 'lib/ecrire/onboarding/controllers/databases_controller.rb', line 5

def index; end