Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
90a8e069
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,发现更多精彩内容 >>
提交
90a8e069
编写于
7月 31, 2017
作者:
D
David Heinemeier Hansson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use config/storage.yml as part of the skeleton and loading
上级
54663f55
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
48 addition
and
43 deletion
+48
-43
activestorage/README.md
activestorage/README.md
+1
-1
activestorage/config/storage_services.yml
activestorage/config/storage_services.yml
+0
-34
activestorage/lib/active_storage/engine.rb
activestorage/lib/active_storage/engine.rb
+1
-1
activestorage/lib/active_storage/service.rb
activestorage/lib/active_storage/service.rb
+1
-1
railties/lib/rails/generators/rails/app/app_generator.rb
railties/lib/rails/generators/rails/app/app_generator.rb
+8
-3
railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
...rails/app/templates/config/environments/development.rb.tt
+1
-1
railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
.../rails/app/templates/config/environments/production.rb.tt
+1
-1
railties/lib/rails/generators/rails/app/templates/config/storage.yml
...b/rails/generators/rails/app/templates/config/storage.yml
+34
-0
railties/test/generators/app_generator_test.rb
railties/test/generators/app_generator_test.rb
+1
-1
未找到文件。
activestorage/README.md
浏览文件 @
90a8e069
...
@@ -91,7 +91,7 @@ Variation of image attachment:
...
@@ -91,7 +91,7 @@ Variation of image attachment:
2.
Add
`require "active_storage"`
to config/application.rb, after
`require "rails/all"`
line.
2.
Add
`require "active_storage"`
to config/application.rb, after
`require "rails/all"`
line.
3.
Run
`rails activestorage:install`
to create needed directories, migrations, and configuration.
3.
Run
`rails activestorage:install`
to create needed directories, migrations, and configuration.
4.
Configure the storage service in
`config/environments/*`
with
`config.active_storage.service = :local`
4.
Configure the storage service in
`config/environments/*`
with
`config.active_storage.service = :local`
that references the services configured in
`config/storage
_services
.yml`
.
that references the services configured in
`config/storage.yml`
.
5.
Optional: Add
`gem "aws-sdk", "~> 2"`
to your Gemfile if you want to use AWS S3.
5.
Optional: Add
`gem "aws-sdk", "~> 2"`
to your Gemfile if you want to use AWS S3.
6.
Optional: Add
`gem "google-cloud-storage", "~> 1.3"`
to your Gemfile if you want to use Google Cloud Storage.
6.
Optional: Add
`gem "google-cloud-storage", "~> 1.3"`
to your Gemfile if you want to use Google Cloud Storage.
7.
Optional: Add
`gem "mini_magick"`
to your Gemfile if you want to use variants.
7.
Optional: Add
`gem "mini_magick"`
to your Gemfile if you want to use variants.
...
...
activestorage/config/storage_services.yml
已删除
100644 → 0
浏览文件 @
54663f55
test
:
service
:
Disk
root
:
<%= Rails.root.join("tmp/storage") %>
local
:
service
:
Disk
root
:
<%= Rails.root.join("storage") %>
# Use rails secrets:edit to set the AWS secrets (as shared:aws:access_key_id|secret_access_key)
amazon
:
service
:
S3
access_key_id
:
<%= Rails.application.secrets.dig(:aws, :access_key_id) %>
secret_access_key
:
<%= Rails.application.secrets.dig(:aws, :secret_access_key) %>
region
:
us-east-1
bucket
:
your_own_bucket
# Remember not to checkin your GCS keyfile to a repository
google
:
service
:
GCS
project
:
your_project
keyfile
:
<%= Rails.root.join("path/to/gcs.keyfile") %>
bucket
:
your_own_bucket
microsoft
:
service
:
Azure
path
:
your_azure_storage_path
storage_account_name
:
your_account_name
storage_access_key
:
<%= Rails.application.secrets.azure[:secret_access_key] %>
container
:
your_container_name
mirror
:
service
:
Mirror
primary
:
local
mirrors
:
[
amazon
,
google
]
activestorage/lib/active_storage/engine.rb
浏览文件 @
90a8e069
...
@@ -31,7 +31,7 @@ class Engine < Rails::Engine # :nodoc:
...
@@ -31,7 +31,7 @@ class Engine < Rails::Engine # :nodoc:
initializer
"active_storage.services"
do
initializer
"active_storage.services"
do
config
.
after_initialize
do
|
app
|
config
.
after_initialize
do
|
app
|
if
config_choice
=
app
.
config
.
active_storage
.
service
if
config_choice
=
app
.
config
.
active_storage
.
service
config_file
=
Pathname
.
new
(
Rails
.
root
.
join
(
"config/storage
_services
.yml"
))
config_file
=
Pathname
.
new
(
Rails
.
root
.
join
(
"config/storage.yml"
))
raise
(
"Couldn't find Active Storage configuration in
#{
config_file
}
"
)
unless
config_file
.
exist?
raise
(
"Couldn't find Active Storage configuration in
#{
config_file
}
"
)
unless
config_file
.
exist?
require
"yaml"
require
"yaml"
...
...
activestorage/lib/active_storage/service.rb
浏览文件 @
90a8e069
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
# * +Mirror+, to be able to use several services to manage attachments.
# * +Mirror+, to be able to use several services to manage attachments.
#
#
# Inside a Rails application, you can set-up your services through the
# Inside a Rails application, you can set-up your services through the
# generated <tt>config/storage
_services
.yml</tt> file and reference one
# generated <tt>config/storage.yml</tt> file and reference one
# of the aforementioned constant under the +service+ key. For example:
# of the aforementioned constant under the +service+ key. For example:
#
#
# local:
# local:
...
...
railties/lib/rails/generators/rails/app/app_generator.rb
浏览文件 @
90a8e069
...
@@ -123,6 +123,7 @@ def config
...
@@ -123,6 +123,7 @@ def config
def
config_when_updating
def
config_when_updating
cookie_serializer_config_exist
=
File
.
exist?
(
"config/initializers/cookies_serializer.rb"
)
cookie_serializer_config_exist
=
File
.
exist?
(
"config/initializers/cookies_serializer.rb"
)
action_cable_config_exist
=
File
.
exist?
(
"config/cable.yml"
)
action_cable_config_exist
=
File
.
exist?
(
"config/cable.yml"
)
active_storage_config_exist
=
File
.
exist?
(
"config/storage.yml"
)
rack_cors_config_exist
=
File
.
exist?
(
"config/initializers/cors.rb"
)
rack_cors_config_exist
=
File
.
exist?
(
"config/initializers/cors.rb"
)
assets_config_exist
=
File
.
exist?
(
"config/initializers/assets.rb"
)
assets_config_exist
=
File
.
exist?
(
"config/initializers/assets.rb"
)
...
@@ -136,6 +137,10 @@ def config_when_updating
...
@@ -136,6 +137,10 @@ def config_when_updating
template
"config/cable.yml"
template
"config/cable.yml"
end
end
if
!
active_storage_config_exist
template
"config/storage.yml"
end
unless
rack_cors_config_exist
unless
rack_cors_config_exist
remove_file
"config/initializers/cors.rb"
remove_file
"config/initializers/cors.rb"
end
end
...
...
railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
浏览文件 @
90a8e069
...
@@ -27,7 +27,7 @@ Rails.application.configure do
...
@@ -27,7 +27,7 @@ Rails.application.configure do
config.cache_store = :null_store
config.cache_store = :null_store
end
end
# Store uploaded files on the local file system (see config/storage
_services
.yml for options)
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
config.active_storage.service = :local
<%- unless options.skip_action_mailer? -%>
<%- unless options.skip_action_mailer? -%>
...
...
railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
浏览文件 @
90a8e069
...
@@ -45,7 +45,7 @@ Rails.application.configure do
...
@@ -45,7 +45,7 @@ Rails.application.configure do
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Store uploaded files on the local file system (see config/storage
_services
.yml for options)
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
config.active_storage.service = :local
<%- unless options[:skip_action_cable] -%>
<%- unless options[:skip_action_cable] -%>
# Mount Action Cable outside main process or domain
# Mount Action Cable outside main process or domain
...
...
railties/lib/rails/generators/rails/app/templates/config/storage.yml
0 → 100644
浏览文件 @
90a8e069
test
:
service
:
Disk
root
:
<%= Rails.root.join("tmp/storage") %>
local
:
service
:
Disk
root
:
<%= Rails.root.join("storage") %>
# Use rails secrets:edit to set the AWS secrets (as shared:aws:access_key_id|secret_access_key)
# amazon:
# service: S3
# access_key_id: <%= Rails.application.secrets.dig(:aws, :access_key_id) %>
# secret_access_key: <%= Rails.application.secrets.dig(:aws, :secret_access_key) %>
# region: us-east-1
# bucket: your_own_bucket
# Remember not to checkin your GCS keyfile to a repository
# google:
# service: GCS
# project: your_project
# keyfile: <%= Rails.root.join("path/to/gcs.keyfile") %>
# bucket: your_own_bucket
# microsoft:
# service: Azure
# path: your_azure_storage_path
# storage_account_name: your_account_name
# storage_access_key: <%= Rails.application.secrets.dig(:azure, :secret_access_key) %>
# container: your_container_name
# mirror:
# service: Mirror
# primary: local
# mirrors: [ amazon, google, microsoft ]
railties/test/generators/app_generator_test.rb
浏览文件 @
90a8e069
...
@@ -64,7 +64,7 @@
...
@@ -64,7 +64,7 @@
config/routes.rb
config/routes.rb
config/secrets.yml
config/secrets.yml
config/spring.rb
config/spring.rb
config/storage
_services
.yml
config/storage.yml
db
db
db/seeds.rb
db/seeds.rb
lib
lib
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录