bullet_train 1.3.11 → 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: 3e978873b55ca6a15b2b500915937a0eaa092d9bc5a8a8b2f8dc1f10d6ac27f7
4
- data.tar.gz: 8756fd456af1bc3f70429c78234175e00d28fbefe04fa9253182831fefb084a3
3
+ metadata.gz: cebee7b2e16992167700e7be651823752180c0a94ac4dceb2000bb1363b62d9e
4
+ data.tar.gz: bb64b9ea40fea04936812eabf14cc9b0261c4d11a2f8ff9c62de17ea756de55d
5
5
  SHA512:
6
- metadata.gz: 9988ba16cd8b3c98161e4ba478e97f93b87152211592c93b62f4ba898fd6131e3a6abfd3190e0975a9e7ab1bef9fb53b3c0e783d481823dd0e37423fa44f4845
7
- data.tar.gz: 42f98d7b289251a81263282265b307e4f3901e8e5379c7b95f4ba4451318e1aa4b9f9b99a1b96a75c0e9aa4ee3cd2afd5c4b82896705e3542bbe63d13b9a0f01
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
@@ -9,7 +9,7 @@ module Invitations::Base
9
9
 
10
10
  accepts_nested_attributes_for :membership
11
11
 
12
- validates :email, presence: true
12
+ validates :email, presence: true, uniqueness: {scope: :team}
13
13
 
14
14
  after_create :set_added_by_membership
15
15
  after_create :send_invitation_email
@@ -21,6 +21,8 @@ module Memberships::Base
21
21
  # Image uploading
22
22
  has_one_attached :user_profile_photo
23
23
 
24
+ validates :user_email, uniqueness: {scope: :team}
25
+
24
26
  after_destroy do
25
27
  # if we're destroying a user's membership to the team they have set as
26
28
  # current, then we need to remove that so they don't get an error.
@@ -71,7 +71,7 @@ module Users::Base
71
71
  def create_default_team
72
72
  # This creates a `Membership`, because `User` `has_many :teams, through: :memberships`
73
73
  default_team = teams.create(name: I18n.t("teams.new.default_team_name"), time_zone: time_zone)
74
- memberships.find_by(team: default_team).update role_ids: [Role.admin.id]
74
+ memberships.find_by(team: default_team).update(user_email: email, role_ids: [Role.admin.id])
75
75
  update(current_team: default_team)
76
76
  end
77
77
 
@@ -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
  #
@@ -59,6 +59,7 @@ en:
59
59
  resent: 'Invitation was successfully resent.'
60
60
  resent_error: Sorry, we couldn't find an invitation to resend.
61
61
  doesnt_exist: Sorry, but we couldn't find your invitation. Please contact an administrator on the team to have them send you another one.
62
+ duplicate: 'Sorry, a member with the email %{user_email} has already been invited.'
62
63
  values:
63
64
  name: 'Invitation to Join %{team_name}'
64
65
  account:
@@ -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.11"
2
+ VERSION = "1.3.13"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.11
4
+ version: 1.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-22 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard