Class: Bricks::Database
- Inherits:
-
Base
- Object
- Base
- Bricks::Database
show all
- Defined in:
- lib/active_admin/generator/bricks/database.rb
Instance Attribute Summary
Attributes inherited from Base
#base_path, #context
Instance Method Summary
collapse
Methods inherited from Base
#apply?, #ask, #choose, #commit_all, #format, #initialize, #say, #template, #title, #yes?
Constructor Details
This class inherits a constructor from Bricks::Base
Instance Method Details
#after_bundle ⇒ Object
21
22
23
24
|
# File 'lib/active_admin/generator/bricks/database.rb', line 21
def after_bundle
rake "db:drop"
rake "db:create"
end
|
#before_bundle ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/active_admin/generator/bricks/database.rb', line 4
def before_bundle
remove_file "config/database.yml"
gsub_file 'Gemfile', /gem 'sqlite3'\n/, ''
@adapter = choose "Database used in development?", [["SQLite", :sqlite], ["PostgreSQL", :pg], ["MySQL", :mysql]]
if @adapter != :sqlite
@database = ask "Development database name:"
@username = ask "Username:"
@password = ask "Password:"
end
send("configure_#{@adapter}")
template "config/database.yml"
commit_all "Database configured"
end
|
30
31
32
|
# File 'lib/active_admin/generator/bricks/database.rb', line 30
def configure_mysql
gem 'mysql2', group: 'development'
end
|
34
35
36
|
# File 'lib/active_admin/generator/bricks/database.rb', line 34
def configure_pg
gem 'pg', group: 'development'
end
|
26
27
28
|
# File 'lib/active_admin/generator/bricks/database.rb', line 26
def configure_sqlite
gem 'sqlite3', group: 'development'
end
|