Skip to content

Commit 61a9c1a

Browse files
Ruby code block indentation issue fix
[skip ci] indentation fix [skip ci] review changes added [skip ci] indentation fix
1 parent 9044d35 commit 61a9c1a

File tree

10 files changed

+63
-60
lines changed

10 files changed

+63
-60
lines changed

actionpack/CHANGELOG.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
This is very useful in situations where you only want to add a required param that is part of the route's URL but for other route not append an extraneous query param.
8181

8282
Given the following router...
83+
8384
```ruby
8485
Rails.application.routes.draw do
8586
scope ":account_id" do
@@ -91,12 +92,13 @@
9192
```
9293

9394
And given the following `ApplicationController`
95+
9496
```ruby
95-
class ApplicationController < ActionController::Base
96-
def default_url_options
97-
{ path_params: { account_id: "foo" } }
98-
end
97+
class ApplicationController < ActionController::Base
98+
def default_url_options
99+
{ path_params: { account_id: "foo" } }
99100
end
101+
end
100102
```
101103

102104
The standard url_for helper and friends will now behave as follows:

activejob/CHANGELOG.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
This method lets job authors define a block which will be run when a job is about to be discarded. For example:
99

1010
```ruby
11-
class AfterDiscardJob < ActiveJob::Base
12-
after_discard do |job, exception|
13-
Rails.logger.info("#{job.class} raised an exception: #{exception}")
14-
end
15-
16-
def perform
17-
raise StandardError
18-
end
11+
class AfterDiscardJob < ActiveJob::Base
12+
after_discard do |job, exception|
13+
Rails.logger.info("#{job.class} raised an exception: #{exception}")
1914
end
15+
16+
def perform
17+
raise StandardError
18+
end
19+
end
2020
```
2121

2222
The above job will run the block passed to `after_discard` after the job is discarded. The exception will

activemodel/CHANGELOG.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
to consider both character count and byte size while keeping the character length validation in place.
3030

3131
```ruby
32-
user = User.new(password: "a" * 73) # 73 characters
33-
user.valid? # => false
34-
user.errors[:password] # => ["is too long"]
32+
user = User.new(password: "a" * 73) # 73 characters
33+
user.valid? # => false
34+
user.errors[:password] # => ["is too long"]
3535

3636

37-
user = User.new(password: "" * 25) # 25 characters, 75 bytes
38-
user.valid? # => false
39-
user.errors[:password] # => ["is too long"]
37+
user = User.new(password: "" * 25) # 25 characters, 75 bytes
38+
user.valid? # => false
39+
user.errors[:password] # => ["is too long"]
4040
```
4141

4242
*ChatGPT*, *Guillermo Iguaran*

activerecord/CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -788,15 +788,15 @@
788788
Before:
789789

790790
```ruby
791-
serialize :content, JSON
792-
serialize :backtrace, Array
791+
serialize :content, JSON
792+
serialize :backtrace, Array
793793
```
794794

795795
After:
796796

797797
```ruby
798-
serialize :content, coder: JSON
799-
serialize :backtrace, type: Array
798+
serialize :content, coder: JSON
799+
serialize :backtrace, type: Array
800800
```
801801

802802
*Jean Boussier*

activestorage/CHANGELOG.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,21 +144,21 @@
144144
145145
In the following example, the code failed to upload all but the last file to the configured service.
146146
```ruby
147-
ActiveRecord::Base.transaction do
148-
user.attachments.attach({
149-
content_type: "text/plain",
150-
filename: "dummy.txt",
151-
io: ::StringIO.new("dummy"),
152-
})
153-
user.attachments.attach({
154-
content_type: "text/plain",
155-
filename: "dummy2.txt",
156-
io: ::StringIO.new("dummy2"),
157-
})
158-
end
147+
ActiveRecord::Base.transaction do
148+
user.attachments.attach({
149+
content_type: "text/plain",
150+
filename: "dummy.txt",
151+
io: ::StringIO.new("dummy"),
152+
})
153+
user.attachments.attach({
154+
content_type: "text/plain",
155+
filename: "dummy2.txt",
156+
io: ::StringIO.new("dummy2"),
157+
})
158+
end
159159
160-
assert_equal 2, user.attachments.count
161-
assert user.attachments.first.service.exist?(user.attachments.first.key) # Fails
160+
assert_equal 2, user.attachments.count
161+
assert user.attachments.first.service.exist?(user.attachments.first.key) # Fails
162162
```
163163
164164
This was addressed by keeping track of the subchanges pending upload, and uploading them

guides/source/7_0_release_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Please refer to the [Changelog][action-view] for detailed changes.
9696
#=> <input type="hidden" name="_method" value="post" autocomplete="off" />
9797
# After
9898
#=> <input type="hidden" name="_method" value="patch" autocomplete="off" />
99+
```
99100
100101
Action Mailer
101102
-------------

guides/source/7_1_release_notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ Please refer to the [Changelog][active-model] for detailed changes.
588588

589589
* Add support for beginless ranges to `inclusivity/exclusivity` validators.
590590

591-
```ruby
591+
```ruby
592592
validates_inclusion_of :birth_date, in: -> { (..Date.today) }
593593
```
594594

guides/source/active_support_instrumentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ View Timings from Instrumentation in Your Browser
102102
Rails implements the [Server Timing](https://www.w3.org/TR/server-timing/) standard to make timing information available in the web browser. To enable, edit your environment configuration (usually `development.rb` as this is most-used in development) to include the following:
103103

104104
```ruby
105-
config.server_timing = true
105+
config.server_timing = true
106106
```
107107

108108
Once configured (including restarting your server), you can go to the Developer Tools pane of your browser, then select Network and reload your page. You can then select any request to your Rails server, and will see server timings in the timings tab. For an example of doing this, see the [Firefox Documentation](https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/request_details/index.html#server-timing).

guides/source/security.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ INFO: _A common pitfall in Ruby's regular expressions is to match the string's b
527527
Ruby uses a slightly different approach than many other languages to match the end and the beginning of a string. That is why even many Ruby and Rails books get this wrong. So how is this a security threat? Say you wanted to loosely validate a URL field and you used a simple regular expression like this:
528528

529529
```ruby
530-
/^https?:\/\/[^\n]+$/i
530+
/^https?:\/\/[^\n]+$/i
531531
```
532532

533533
This may work fine in some languages. However, _in Ruby `^` and `$` match the **line** beginning and line end_. And thus a URL like this passes the filter without problems:
@@ -541,22 +541,22 @@ http://hi.com
541541
This URL passes the filter because the regular expression matches - the second line, the rest does not matter. Now imagine we had a view that showed the URL like this:
542542

543543
```ruby
544-
link_to "Homepage", @user.homepage
544+
link_to "Homepage", @user.homepage
545545
```
546546

547547
The link looks innocent to visitors, but when it's clicked, it will execute the JavaScript function "exploit_code" or any other JavaScript the attacker provides.
548548

549549
To fix the regular expression, `\A` and `\z` should be used instead of `^` and `$`, like so:
550550

551551
```ruby
552-
/\Ahttps?:\/\/[^\n]+\z/i
552+
/\Ahttps?:\/\/[^\n]+\z/i
553553
```
554554

555555
Since this is a frequent mistake, the format validator (validates_format_of) now raises an exception if the provided regular expression starts with ^ or ends with $. If you do need to use ^ and $ instead of \A and \z (which is rare), you can set the :multiline option to true, like so:
556556

557557
```ruby
558-
# content should include a line "Meanwhile" anywhere in the string
559-
validates :content, format: { with: /^Meanwhile$/, multiline: true }
558+
# content should include a line "Meanwhile" anywhere in the string
559+
validates :content, format: { with: /^Meanwhile$/, multiline: true }
560560
```
561561

562562
Note that this only protects you against the most common mistake when using the format validator - you always need to keep in mind that ^ and $ match the **line** beginning and line end in Ruby, and not the beginning and end of a string.
@@ -1143,7 +1143,7 @@ browser automatically upgrades to HTTPS for current and future connections.
11431143
The header is added to the response when enabling the `force_ssl` option:
11441144

11451145
```ruby
1146-
config.force_ssl = true
1146+
config.force_ssl = true
11471147
```
11481148

11491149
[`Strict-Transport-Security`]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security

guides/source/upgrading_ruby_on_rails.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,10 +2292,10 @@ Rails 4.0 no longer supports loading plugins from `vendor/plugins`. You must rep
22922292
* Rails 4.0 requires that scopes use a callable object such as a Proc or lambda:
22932293

22942294
```ruby
2295-
scope :active, where(active: true)
2295+
scope :active, where(active: true)
22962296
2297-
# becomes
2298-
scope :active, -> { where active: true }
2297+
# becomes
2298+
scope :active, -> { where active: true }
22992299
```
23002300

23012301
* Rails 4.0 has deprecated `ActiveRecord::Fixtures` in favor of `ActiveRecord::FixtureSet`.
@@ -2356,9 +2356,9 @@ Rails 4.0 extracted Active Resource to its own gem. If you still need the featur
23562356
* Rails 4.0 introduces `ActiveSupport::KeyGenerator` and uses this as a base from which to generate and verify signed cookies (among other things). Existing signed cookies generated with Rails 3.x will be transparently upgraded if you leave your existing `secret_token` in place and add the new `secret_key_base`.
23572357

23582358
```ruby
2359-
# config/initializers/secret_token.rb
2360-
Myapp::Application.config.secret_token = 'existing secret token'
2361-
Myapp::Application.config.secret_key_base = 'new secret key base'
2359+
# config/initializers/secret_token.rb
2360+
Myapp::Application.config.secret_token = 'existing secret token'
2361+
Myapp::Application.config.secret_key_base = 'new secret key base'
23622362
```
23632363

23642364
Please note that you should wait to set `secret_key_base` until you have 100% of your userbase on Rails 4.x and are reasonably sure you will not need to rollback to Rails 3.x. This is because cookies signed based on the new `secret_key_base` in Rails 4.x are not backwards compatible with Rails 3.x. You are free to leave your existing `secret_token` in place, not set the new `secret_key_base`, and ignore the deprecation warnings until you are reasonably sure that your upgrade is otherwise complete.
@@ -2422,14 +2422,14 @@ Rails 4.0 extracted Active Resource to its own gem. If you still need the featur
24222422
* Rails 4.0 requires that routes using `match` must specify the request method. For example:
24232423

24242424
```ruby
2425-
# Rails 3.x
2426-
match '/' => 'root#index'
2425+
# Rails 3.x
2426+
match '/' => 'root#index'
24272427
2428-
# becomes
2429-
match '/' => 'root#index', via: :get
2428+
# becomes
2429+
match '/' => 'root#index', via: :get
24302430
2431-
# or
2432-
get '/' => 'root#index'
2431+
# or
2432+
get '/' => 'root#index'
24332433
```
24342434

24352435
* Rails 4.0 has removed `ActionDispatch::BestStandardsSupport` middleware, `<!DOCTYPE html>` already triggers standards mode per https://msdn.microsoft.com/en-us/library/jj676915(v=vs.85).aspx and ChromeFrame header has been moved to `config.action_dispatch.default_headers`.
@@ -2446,10 +2446,10 @@ Rails 4.0 extracted Active Resource to its own gem. If you still need the featur
24462446
* Rails 4.0 allows configuration of HTTP headers by setting `config.action_dispatch.default_headers`. The defaults are as follows:
24472447

24482448
```ruby
2449-
config.action_dispatch.default_headers = {
2450-
'X-Frame-Options' => 'SAMEORIGIN',
2451-
'X-XSS-Protection' => '1; mode=block'
2452-
}
2449+
config.action_dispatch.default_headers = {
2450+
'X-Frame-Options' => 'SAMEORIGIN',
2451+
'X-XSS-Protection' => '1; mode=block'
2452+
}
24532453
```
24542454

24552455
Please note that if your application is dependent on loading certain pages in a `<frame>` or `<iframe>`, then you may need to explicitly set `X-Frame-Options` to `ALLOW-FROM ...` or `ALLOWALL`.

0 commit comments

Comments
 (0)