bullet_train 1.3.12 → 1.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cebee7b2e16992167700e7be651823752180c0a94ac4dceb2000bb1363b62d9e
|
4
|
+
data.tar.gz: bb64b9ea40fea04936812eabf14cc9b0261c4d11a2f8ff9c62de17ea756de55d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4861d4e94ad6060fae8d4ea6859c6569c9acb3c1f7765675cee1d6d473850657ae2a7c6fcdff2f5e89b5524575ff11b9dca3d962ab732502b6615c255bd06ff
|
7
|
+
data.tar.gz: dec3c199b727d7dac9e9f9b188b332aa049dddbf3380c7d156b07ca91903d46ccf473ee339d1b238d0588953035bd28454fce16acf1a68ba14baf3e415386063
|
@@ -85,15 +85,14 @@ module Controllers::Base
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
def set_locale
|
89
|
-
|
88
|
+
def set_locale(&action)
|
89
|
+
locale = [
|
90
90
|
current_user&.locale,
|
91
91
|
current_user&.current_team&.locale,
|
92
92
|
http_accept_language.compatible_language_from(I18n.available_locales),
|
93
93
|
I18n.default_locale.to_s
|
94
94
|
].compact.find { |potential_locale| I18n.available_locales.include?(potential_locale.to_sym) }
|
95
|
-
|
96
|
-
I18n.locale = I18n.default_locale
|
95
|
+
I18n.with_locale(locale, &action)
|
97
96
|
end
|
98
97
|
|
99
98
|
# Whitelist the account namespace and prevent JavaScript
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module DocumentationSupport
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
|
+
BULLET_TRAIN_BASE_PATH = `bundle show bullet_train`.chomp
|
5
|
+
|
4
6
|
def docs
|
5
7
|
target = params[:page].presence || "index"
|
6
8
|
|
@@ -8,8 +10,7 @@ module DocumentationSupport
|
|
8
10
|
# all_paths = ([Rails.root.to_s] + `bundle show --paths`.lines.map(&:chomp))
|
9
11
|
# @path = all_paths.map { |path| path + "/docs/#{target}.md" }.detect { |path| File.exist?(path) }
|
10
12
|
|
11
|
-
|
12
|
-
@path = `bundle show bullet_train`.chomp + "/docs/#{target}.md"
|
13
|
+
@path = "#{BULLET_TRAIN_BASE_PATH}/docs/#{target}.md"
|
13
14
|
|
14
15
|
render :docs, layout: "docs"
|
15
16
|
end
|
data/config/locales/en/base.yml
CHANGED
@@ -10,9 +10,9 @@
|
|
10
10
|
#
|
11
11
|
# <%= t("hello") %>
|
12
12
|
#
|
13
|
-
# To use a different locale, set it with `I18n.
|
13
|
+
# To use a different locale, set it with `I18n.with_locale`:
|
14
14
|
#
|
15
|
-
# I18n.
|
15
|
+
# I18n.with_locale(:es, &block)
|
16
16
|
#
|
17
17
|
# This would use the information in config/locales/es.yml.
|
18
18
|
#
|
@@ -9,6 +9,7 @@ In addition, Bullet Train has integrated the direct-uploads feature of Active St
|
|
9
9
|
## Example
|
10
10
|
|
11
11
|
The following steps illustrate how to add a `document` file attachment to a `Post` model.
|
12
|
+
|
12
13
|
Add the following to `app/models/post.rb`:
|
13
14
|
|
14
15
|
```ruby
|
@@ -22,3 +23,30 @@ Run the following command to generate the scaffolding for the `document` field o
|
|
22
23
|
```bash
|
23
24
|
./bin/super-scaffold crud-field Post document:file_field
|
24
25
|
```
|
26
|
+
|
27
|
+
## Multiple Attachment Example
|
28
|
+
|
29
|
+
The following steps illustrate how to add multiple `document` file attachments to a `Post` model.
|
30
|
+
|
31
|
+
Add the following to `app/models/post.rb`:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
has_many_attached :documents
|
35
|
+
```
|
36
|
+
|
37
|
+
Note, no database migration is required as ActiveStorage uses its own tables to store the attachments.
|
38
|
+
|
39
|
+
Run the following command to generate the scaffolding for the `documents` field on the `Post` model:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
./bin/super-scaffold crud-field Post documents:file_field{multiple}
|
43
|
+
```
|
44
|
+
|
45
|
+
## Generating a Model & Super Scaffold Example
|
46
|
+
|
47
|
+
If you're starting fresh, and don't have an existing model you can do something like this:
|
48
|
+
|
49
|
+
```
|
50
|
+
rails g model Project team:references name:string specification:attachment documents:attachments
|
51
|
+
bin/super-scaffold crud Project Team name:text_field specification:file_field documents:file_field{multiple}
|
52
|
+
```
|
data/lib/bullet_train/version.rb
CHANGED