bullet_train 1.3.12 → 1.3.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff63727028d8970aacd62bb659702ef467d8ee0627935977b444cb49e77f1344
4
- data.tar.gz: 5f136b1f3c5c320cfecbcb52103f327fd48e043647e54473db02b2c6c5a2df3e
3
+ metadata.gz: cebee7b2e16992167700e7be651823752180c0a94ac4dceb2000bb1363b62d9e
4
+ data.tar.gz: bb64b9ea40fea04936812eabf14cc9b0261c4d11a2f8ff9c62de17ea756de55d
5
5
  SHA512:
6
- metadata.gz: 2d5d9b223e72b434743d32e1e82902d4b9ca5eec1379420d2f5bf8afaeae25987cc10e111aaf7623cd5ad37025fd055e86457dc816b17ba29c519bb4da88f066
7
- data.tar.gz: '0539a2acd42bd86c633c1733e89e4bd0837775b5786d15732f0f36bbe07f38c8f3fc395973877d56d7b7948033f945ac89b163e73904fe33cc5a5f2f14821142'
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
- I18n.locale = [
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
- yield
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
- # TODO Trying to just brute force this for now.
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
@@ -10,9 +10,9 @@
10
10
  #
11
11
  # <%= t("hello") %>
12
12
  #
13
- # To use a different locale, set it with `I18n.locale`:
13
+ # To use a different locale, set it with `I18n.with_locale`:
14
14
  #
15
- # I18n.locale = :es
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
+ ```
@@ -1,3 +1,3 @@
1
1
  module BulletTrain
2
- VERSION = "1.3.12"
2
+ VERSION = "1.3.13"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.12
4
+ version: 1.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver