Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
75e0ee86
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
75e0ee86
编写于
4月 08, 2014
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14633 from matthewd/narrow_database_url
Only apply DATABASE_URL for Rails.env
上级
77692ff9
d72a0cbc
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
251 addition
and
101 deletion
+251
-101
activerecord/lib/active_record/connection_adapters/connection_specification.rb
...ve_record/connection_adapters/connection_specification.rb
+3
-3
activerecord/lib/active_record/connection_handling.rb
activerecord/lib/active_record/connection_handling.rb
+6
-29
activerecord/test/cases/connection_adapters/connection_handler_test.rb
...test/cases/connection_adapters/connection_handler_test.rb
+45
-26
railties/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml
...rators/rails/app/templates/config/databases/frontbase.yml
+23
-3
railties/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml
...enerators/rails/app/templates/config/databases/ibm_db.yml
+23
-3
railties/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml
.../generators/rails/app/templates/config/databases/jdbc.yml
+12
-3
railties/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml
...rators/rails/app/templates/config/databases/jdbcmysql.yml
+24
-3
railties/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml
...s/rails/app/templates/config/databases/jdbcpostgresql.yml
+23
-3
railties/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml
...tors/rails/app/templates/config/databases/jdbcsqlite3.yml
+2
-3
railties/lib/rails/generators/rails/app/templates/config/databases/mysql.yml
...generators/rails/app/templates/config/databases/mysql.yml
+21
-5
railties/lib/rails/generators/rails/app/templates/config/databases/oracle.yml
...enerators/rails/app/templates/config/databases/oracle.yml
+23
-3
railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml
...ators/rails/app/templates/config/databases/postgresql.yml
+21
-5
railties/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml
...nerators/rails/app/templates/config/databases/sqlite3.yml
+2
-9
railties/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml
...rators/rails/app/templates/config/databases/sqlserver.yml
+23
-3
未找到文件。
activerecord/lib/active_record/connection_adapters/connection_specification.rb
浏览文件 @
75e0ee86
...
...
@@ -33,7 +33,7 @@ class ConnectionUrlResolver # :nodoc:
def
initialize
(
url
)
raise
"Database URL cannot be empty"
if
url
.
blank?
@uri
=
URI
.
parse
(
url
)
@adapter
=
@uri
.
scheme
@adapter
=
@uri
.
scheme
.
gsub
(
'-'
,
'_'
)
@adapter
=
"postgresql"
if
@adapter
==
"postgres"
if
@uri
.
opaque
...
...
@@ -220,10 +220,10 @@ def resolve_string_connection(spec)
# an environment key or a URL spec, so we have deprecated
# this ambiguous behaviour and in the future this function
# can be removed in favor of resolve_url_connection.
if
configurations
.
key?
(
spec
)
if
configurations
.
key?
(
spec
)
||
spec
!~
/:/
ActiveSupport
::
Deprecation
.
warn
"Passing a string to ActiveRecord::Base.establish_connection "
\
"for a configuration lookup is deprecated, please pass a symbol (
#{
spec
.
to_sym
.
inspect
}
) instead"
resolve_
connection
(
configurations
[
spec
]
)
resolve_
symbol_connection
(
spec
)
else
resolve_url_connection
(
spec
)
end
...
...
activerecord/lib/active_record/connection_handling.rb
浏览文件 @
75e0ee86
...
...
@@ -58,9 +58,9 @@ def establish_connection(spec = nil)
end
class
MergeAndResolveDefaultUrlConfig
# :nodoc:
def
initialize
(
raw_configurations
,
url
=
ENV
[
'DATABASE_URL'
]
)
def
initialize
(
raw_configurations
)
@raw_config
=
raw_configurations
.
dup
@
url
=
url
@
env
=
DEFAULT_ENV
.
call
.
to_s
end
# Returns fully resolved connection hashes.
...
...
@@ -71,33 +71,10 @@ def resolve
private
def
config
if
@url
raw_merged_into_default
else
@raw_config
end
end
def
raw_merged_into_default
default
=
default_url_hash
@raw_config
.
each
do
|
env
,
values
|
default
[
env
]
=
values
||
{}
default
[
env
].
merge!
(
"url"
=>
@url
)
{
|
h
,
v1
,
v2
|
v1
||
v2
}
if
default
[
env
].
is_a?
(
Hash
)
end
default
end
# When the raw configuration is not present and ENV['DATABASE_URL']
# is available we return a hash with the connection information in
# the connection URL. This hash responds to any string key with
# resolved connection information.
def
default_url_hash
Hash
.
new
do
|
hash
,
key
|
hash
[
key
]
=
if
key
.
is_a?
String
ActiveRecord
::
ConnectionAdapters
::
ConnectionSpecification
::
ConnectionUrlResolver
.
new
(
@url
).
to_hash
else
nil
@raw_config
.
dup
.
tap
do
|
cfg
|
if
url
=
ENV
[
'DATABASE_URL'
]
cfg
[
@env
]
||=
{}
cfg
[
@env
][
"url"
]
||=
url
end
end
end
...
...
activerecord/test/cases/connection_adapters/connection_handler_test.rb
浏览文件 @
75e0ee86
...
...
@@ -25,35 +25,45 @@ def spec(spec, config)
ConnectionSpecification
::
Resolver
.
new
(
klass
.
new
(
config
).
resolve
).
spec
(
spec
)
end
def
test_resolver_with_database_uri_and_
known
_key
def
test_resolver_with_database_uri_and_
current_env_symbol
_key
ENV
[
'DATABASE_URL'
]
=
"postgres://localhost/foo"
config
=
{
"production"
=>
{
"adapter"
=>
"not_postgres"
,
"database"
=>
"not_foo"
}
}
actual
=
resolve
(
:
production
,
config
)
config
=
{
"
not_
production"
=>
{
"adapter"
=>
"not_postgres"
,
"database"
=>
"not_foo"
}
}
actual
=
resolve
(
:
default_env
,
config
)
expected
=
{
"adapter"
=>
"postgresql"
,
"database"
=>
"foo"
,
"host"
=>
"localhost"
}
assert_equal
expected
,
actual
end
def
test_resolver_with_database_uri_and_
known
_string_key
def
test_resolver_with_database_uri_and_
and_current_env
_string_key
ENV
[
'DATABASE_URL'
]
=
"postgres://localhost/foo"
config
=
{
"
production
"
=>
{
"adapter"
=>
"not_postgres"
,
"database"
=>
"not_foo"
}
}
actual
=
assert_deprecated
{
resolve
(
"
production
"
,
config
)
}
config
=
{
"
default_env
"
=>
{
"adapter"
=>
"not_postgres"
,
"database"
=>
"not_foo"
}
}
actual
=
assert_deprecated
{
resolve
(
"
default_env
"
,
config
)
}
expected
=
{
"adapter"
=>
"postgresql"
,
"database"
=>
"foo"
,
"host"
=>
"localhost"
}
assert_equal
expected
,
actual
end
def
test_resolver_with_database_uri_and_
unknown_symbol
_key
def
test_resolver_with_database_uri_and_
known
_key
ENV
[
'DATABASE_URL'
]
=
"postgres://localhost/foo"
config
=
{
"
not_production"
=>
{
"adapter"
=>
"not_postgres"
,
"database"
=>
"not_foo
"
}
}
config
=
{
"
production"
=>
{
"adapter"
=>
"not_postgres"
,
"database"
=>
"not_foo"
,
"host"
=>
"localhost
"
}
}
actual
=
resolve
(
:production
,
config
)
expected
=
{
"adapter"
=>
"
postgresql"
,
"database"
=>
"
foo"
,
"host"
=>
"localhost"
}
expected
=
{
"adapter"
=>
"
not_postgres"
,
"database"
=>
"not_
foo"
,
"host"
=>
"localhost"
}
assert_equal
expected
,
actual
end
def
test_resolver_with_database_uri_and_unknown_s
tring
_key
def
test_resolver_with_database_uri_and_unknown_s
ymbol
_key
ENV
[
'DATABASE_URL'
]
=
"postgres://localhost/foo"
config
=
{
"not_production"
=>
{
"adapter"
=>
"not_postgres"
,
"database"
=>
"not_foo"
}
}
assert_raises
AdapterNotSpecified
do
spec
(
"production"
,
config
)
resolve
(
:production
,
config
)
end
end
def
test_resolver_with_database_uri_and_unknown_string_key
ENV
[
'DATABASE_URL'
]
=
"postgres://localhost/foo"
config
=
{
"not_production"
=>
{
"adapter"
=>
"not_postgres"
,
"database"
=>
"not_foo"
}
}
assert_deprecated
do
assert_raises
AdapterNotSpecified
do
spec
(
"production"
,
config
)
end
end
end
...
...
@@ -73,16 +83,24 @@ def test_jdbc_url
def
test_environment_does_not_exist_in_config_url_does_exist
ENV
[
'DATABASE_URL'
]
=
"postgres://localhost/foo"
config
=
{
"not_
production
"
=>
{
"adapter"
=>
"not_postgres"
,
"database"
=>
"not_foo"
}
}
config
=
{
"not_
default_env
"
=>
{
"adapter"
=>
"not_postgres"
,
"database"
=>
"not_foo"
}
}
actual
=
klass
.
new
(
config
).
resolve
expect_prod
=
{
"adapter"
=>
"postgresql"
,
"database"
=>
"foo"
,
"host"
=>
"localhost"
}
assert_equal
expect_prod
,
actual
[
"production"
]
assert_equal
expect_prod
,
actual
[
"default_env"
]
end
def
test_url_with_hyphenated_scheme
ENV
[
'DATABASE_URL'
]
=
"ibm-db://localhost/foo"
config
=
{
"default_env"
=>
{
"adapter"
=>
"not_postgres"
,
"database"
=>
"not_foo"
,
"host"
=>
"localhost"
}
}
actual
=
resolve
(
:default_env
,
config
)
expected
=
{
"adapter"
=>
"ibm_db"
,
"database"
=>
"foo"
,
"host"
=>
"localhost"
}
assert_equal
expected
,
actual
end
def
test_string_connection
config
=
{
"
production
"
=>
"postgres://localhost/foo"
}
config
=
{
"
default_env
"
=>
"postgres://localhost/foo"
}
actual
=
klass
.
new
(
config
).
resolve
expected
=
{
"
production
"
=>
expected
=
{
"
default_env
"
=>
{
"adapter"
=>
"postgresql"
,
"database"
=>
"foo"
,
"host"
=>
"localhost"
...
...
@@ -92,9 +110,9 @@ def test_string_connection
end
def
test_url_sub_key
config
=
{
"
production
"
=>
{
"url"
=>
"postgres://localhost/foo"
}
}
config
=
{
"
default_env
"
=>
{
"url"
=>
"postgres://localhost/foo"
}
}
actual
=
klass
.
new
(
config
).
resolve
expected
=
{
"
production
"
=>
expected
=
{
"
default_env
"
=>
{
"adapter"
=>
"postgresql"
,
"database"
=>
"foo"
,
"host"
=>
"localhost"
...
...
@@ -123,9 +141,10 @@ def test_blank_with_database_url
expected
=
{
"adapter"
=>
"postgresql"
,
"database"
=>
"foo"
,
"host"
=>
"localhost"
}
assert_equal
expected
,
actual
[
"production"
]
assert_equal
expected
,
actual
[
"development"
]
assert_equal
expected
,
actual
[
"test"
]
assert_equal
expected
,
actual
[
"default_env"
]
assert_equal
nil
,
actual
[
"production"
]
assert_equal
nil
,
actual
[
"development"
]
assert_equal
nil
,
actual
[
"test"
]
assert_equal
nil
,
actual
[
:production
]
assert_equal
nil
,
actual
[
:development
]
assert_equal
nil
,
actual
[
:test
]
...
...
@@ -134,9 +153,9 @@ def test_blank_with_database_url
def
test_url_sub_key_with_database_url
ENV
[
'DATABASE_URL'
]
=
"NOT-POSTGRES://localhost/NOT_FOO"
config
=
{
"
production
"
=>
{
"url"
=>
"postgres://localhost/foo"
}
}
config
=
{
"
default_env
"
=>
{
"url"
=>
"postgres://localhost/foo"
}
}
actual
=
klass
.
new
(
config
).
resolve
expected
=
{
"
production
"
=>
expected
=
{
"
default_env
"
=>
{
"adapter"
=>
"postgresql"
,
"database"
=>
"foo"
,
"host"
=>
"localhost"
...
...
@@ -148,9 +167,9 @@ def test_url_sub_key_with_database_url
def
test_merge_no_conflicts_with_database_url
ENV
[
'DATABASE_URL'
]
=
"postgres://localhost/foo"
config
=
{
"
production
"
=>
{
"pool"
=>
"5"
}
}
config
=
{
"
default_env
"
=>
{
"pool"
=>
"5"
}
}
actual
=
klass
.
new
(
config
).
resolve
expected
=
{
"
production
"
=>
expected
=
{
"
default_env
"
=>
{
"adapter"
=>
"postgresql"
,
"database"
=>
"foo"
,
"host"
=>
"localhost"
,
...
...
@@ -163,9 +182,9 @@ def test_merge_no_conflicts_with_database_url
def
test_merge_conflicts_with_database_url
ENV
[
'DATABASE_URL'
]
=
"postgres://localhost/foo"
config
=
{
"
production
"
=>
{
"adapter"
=>
"NOT-POSTGRES"
,
"database"
=>
"NOT-FOO"
,
"pool"
=>
"5"
}
}
config
=
{
"
default_env
"
=>
{
"adapter"
=>
"NOT-POSTGRES"
,
"database"
=>
"NOT-FOO"
,
"pool"
=>
"5"
}
}
actual
=
klass
.
new
(
config
).
resolve
expected
=
{
"
production
"
=>
expected
=
{
"
default_env
"
=>
{
"adapter"
=>
"postgresql"
,
"database"
=>
"foo"
,
"host"
=>
"localhost"
,
...
...
railties/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml
浏览文件 @
75e0ee86
...
...
@@ -23,7 +23,27 @@ test:
<<
:
*default
database
:
<%= app_name %>_test
# Do not keep production credentials in the repository,
# instead read the configuration from the environment.
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="frontbase://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%%= ENV['DATABASE_URL'] %>
#
production
:
url
:
<%%= ENV["DATABASE_URL"] %>
<<
:
*default
database
:
<%= app_name %>_production
username
:
<%= app_name %>
password
:
<%%= ENV['<%= app_name.upcase %>_DATABASE_PASSWORD'] %>
railties/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml
浏览文件 @
75e0ee86
...
...
@@ -61,7 +61,27 @@ test:
<<
:
*default
database
:
<%= app_name[0,4] %>_tst
# Do not keep production credentials in the repository,
# instead read the configuration from the environment.
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="ibm-db://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%%= ENV['DATABASE_URL'] %>
#
production
:
url
:
<%%= ENV["DATABASE_URL"] %>
<<
:
*default
database
:
<%= app_name %>_production
username
:
<%= app_name %>
password
:
<%%= ENV['<%= app_name.upcase %>_DATABASE_PASSWORD'] %>
railties/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml
浏览文件 @
75e0ee86
...
...
@@ -53,7 +53,16 @@ test:
<<
:
*default
url
:
jdbc:db://localhost/<%= app_name %>_test
# Do not keep production credentials in the repository,
# instead read the configuration from the environment.
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
production
:
url
:
<%%= ENV["DATABASE_URL"] %>
url
:
jdbc:db://localhost/<%= app_name %>_production
username
:
<%= app_name %>
password
:
<%%= ENV['<%= app_name.upcase %>_DATABASE_PASSWORD'] %>
railties/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml
浏览文件 @
75e0ee86
...
...
@@ -26,6 +26,27 @@ test:
<<
:
*default
database
:
<%= app_name %>_test
# Do not keep production credentials in the repository,
# instead read the configuration from the environment.
production
:
<%%= ENV["DATABASE_URL"] %>
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%%= ENV['DATABASE_URL'] %>
#
production
:
<<
:
*default
database
:
<%= app_name %>_production
username
:
<%= app_name %>
password
:
<%%= ENV['<%= app_name.upcase %>_DATABASE_PASSWORD'] %>
railties/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml
浏览文件 @
75e0ee86
...
...
@@ -42,7 +42,27 @@ test:
<<
:
*default
database
:
<%= app_name %>_test
# Do not keep production credentials in the repository,
# instead read the configuration from the environment.
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%%= ENV['DATABASE_URL'] %>
#
production
:
url
:
<%%= ENV["DATABASE_URL"] %>
<<
:
*default
database
:
<%= app_name %>_production
username
:
<%= app_name %>
password
:
<%%= ENV['<%= app_name.upcase %>_DATABASE_PASSWORD'] %>
railties/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml
浏览文件 @
75e0ee86
...
...
@@ -18,7 +18,6 @@ test:
<<
:
*default
database
:
db/test.sqlite3
# Do not keep production credentials in the repository,
# instead read the configuration from the environment.
production
:
url
:
<%%= ENV["DATABASE_URL"] %>
<<
:
*default
database
:
db/production.sqlite3
railties/lib/rails/generators/rails/app/templates/config/databases/mysql.yml
浏览文件 @
75e0ee86
...
...
@@ -32,11 +32,27 @@ test:
<<
:
*default
database
:
<%= app_name %>_test
# Avoid production credentials in the repository,
# instead read the configuration from the environment.
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Example:
# mysql2://myuser:mypass@localhost/somedatabase
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%%= ENV['DATABASE_URL'] %>
#
production
:
url
:
<%%= ENV["DATABASE_URL"] %>
<<
:
*default
database
:
<%= app_name %>_production
username
:
<%= app_name %>
password
:
<%%= ENV['<%= app_name.upcase %>_DATABASE_PASSWORD'] %>
railties/lib/rails/generators/rails/app/templates/config/databases/oracle.yml
浏览文件 @
75e0ee86
...
...
@@ -32,7 +32,27 @@ test:
<<
:
*default
database
:
<%= app_name %>_test
# Do not keep production credentials in the repository,
# instead read the configuration from the environment.
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="oracle://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%%= ENV['DATABASE_URL'] %>
#
production
:
url
:
<%%= ENV["DATABASE_URL"] %>
<<
:
*default
database
:
<%= app_name %>_production
username
:
<%= app_name %>
password
:
<%%= ENV['<%= app_name.upcase %>_DATABASE_PASSWORD'] %>
railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml
浏览文件 @
75e0ee86
...
...
@@ -59,11 +59,27 @@ test:
<<
:
*default
database
:
<%= app_name %>_test
# Do not keep production credentials in the repository,
# instead read the configuration from the environment.
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Example:
# postgres://myuser:mypass@localhost/somedatabase
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%%= ENV['DATABASE_URL'] %>
#
production
:
url
:
<%%= ENV["DATABASE_URL"] %>
<<
:
*default
database
:
<%= app_name %>_production
username
:
<%= app_name %>
password
:
<%%= ENV['<%= app_name.upcase %>_DATABASE_PASSWORD'] %>
railties/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml
浏览文件 @
75e0ee86
...
...
@@ -20,13 +20,6 @@ test:
<<
:
*default
database
:
db/test.sqlite3
# Do not keep production credentials in the repository,
# instead read the configuration from the environment.
#
# Examples:
# sqlite3::memory:
# sqlite3:db/production.sqlite3
# sqlite3:/full/path/to/database.sqlite3
#
production
:
url
:
<%%= ENV["DATABASE_URL"] %>
<<
:
*default
database
:
db/production.sqlite3
railties/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml
浏览文件 @
75e0ee86
...
...
@@ -42,7 +42,27 @@ test:
<<
:
*default
database
:
<%= app_name %>_test
# Do not keep production credentials in the repository,
# instead read the configuration from the environment.
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="sqlserver://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%%= ENV['DATABASE_URL'] %>
#
production
:
url
:
<%%= ENV["DATABASE_URL"] %>
<<
:
*default
database
:
<%= app_name %>_production
username
:
<%= app_name %>
password
:
<%%= ENV['<%= app_name.upcase %>_DATABASE_PASSWORD'] %>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录