Skip to content

Commit f3f36e7

Browse files
Fix syntax highlighting [ci-skip]
This fixes the syntax highlighting of several code snippets by changing the code fences to the correct language.
1 parent f5c92c3 commit f3f36e7

11 files changed

+87
-51
lines changed

guides/source/2_3_release_notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]],
434434

435435
returns
436436

437-
```ruby
437+
```html
438438
<option value="">Choose a product...</option>
439439
<optgroup label="Hats">
440440
<option value="Baseball Cap">Baseball Cap</option>

guides/source/5_1_release_notes.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Secrets will be decrypted in production, using a key stored either in the
104104
Allows specifying common parameters used for all methods in a mailer class in
105105
order to share instance variables, headers, and other common setup.
106106

107-
``` ruby
107+
```ruby
108108
class InvitationsMailer < ApplicationMailer
109109
before_action { @inviter, @invitee = params[:inviter], params[:invitee] }
110110
before_action { @account = params[:inviter].account }
@@ -127,13 +127,13 @@ InvitationsMailer.with(inviter: person_a, invitee: person_b)
127127
Rails 5.1 adds two new methods, `resolve` and `direct`, to the routing
128128
DSL. The `resolve` method allows customizing polymorphic mapping of models.
129129

130-
``` ruby
130+
```ruby
131131
resource :basket
132132

133133
resolve("Basket") { [:basket] }
134134
```
135135

136-
``` erb
136+
```erb
137137
<%= form_for @basket do |form| %>
138138
<!-- basket form -->
139139
<% end %>
@@ -143,7 +143,7 @@ This will generate the singular URL `/basket` instead of the usual `/baskets/:id
143143

144144
The `direct` method allows creation of custom URL helpers.
145145

146-
``` ruby
146+
```ruby
147147
direct(:homepage) { "http://www.rubyonrails.org" }
148148

149149
homepage_url # => "http://www.rubyonrails.org"
@@ -153,7 +153,7 @@ The return value of the block must be a valid argument for the `url_for`
153153
method. So, you can pass a valid string URL, Hash, Array, an
154154
Active Model instance, or an Active Model class.
155155

156-
``` ruby
156+
```ruby
157157
direct :commentable do |model|
158158
[ model, anchor: model.dom_id ]
159159
end
@@ -175,7 +175,7 @@ can generate form tags based on URLs, scopes, or models.
175175

176176
Using just a URL:
177177

178-
``` erb
178+
```erb
179179
<%= form_with url: posts_path do |form| %>
180180
<%= form.text_field :title %>
181181
<% end %>
@@ -189,7 +189,7 @@ Using just a URL:
189189

190190
Adding a scope prefixes the input field names:
191191

192-
``` erb
192+
```erb
193193
<%= form_with scope: :post, url: posts_path do |form| %>
194194
<%= form.text_field :title %>
195195
<% end %>
@@ -203,7 +203,7 @@ Adding a scope prefixes the input field names:
203203

204204
Using a model infers both the URL and scope:
205205

206-
``` erb
206+
```erb
207207
<%= form_with model: Post.new do |form| %>
208208
<%= form.text_field :title %>
209209
<% end %>
@@ -217,7 +217,7 @@ Using a model infers both the URL and scope:
217217

218218
An existing model makes an update form and fills out field values:
219219

220-
``` erb
220+
```erb
221221
<%= form_with model: Post.first do |form| %>
222222
<%= form.text_field :title %>
223223
<% end %>

guides/source/6_1_release_notes.md

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -251,43 +251,57 @@ Please refer to the [Changelog][active-record] for detailed changes.
251251

252252
Before:
253253

254-
User.where(name: "John").create do |john|
255-
User.find_by(name: "David") # => nil
256-
end
254+
```ruby
255+
User.where(name: "John").create do |john|
256+
User.find_by(name: "David") # => nil
257+
end
258+
```
257259

258260
After:
259261

260-
User.where(name: "John").create do |john|
261-
User.find_by(name: "David") # => #<User name: "David", ...>
262-
end
262+
```ruby
263+
User.where(name: "John").create do |john|
264+
User.find_by(name: "David") # => #<User name: "David", ...>
265+
end
266+
```
263267

264268
* Named scope chain does no longer leak scope to class level querying methods.
265269

266-
class User < ActiveRecord::Base
267-
scope :david, -> { User.where(name: "David") }
268-
end
270+
```ruby
271+
class User < ActiveRecord::Base
272+
scope :david, -> { User.where(name: "David") }
273+
end
274+
```
269275

270276
Before:
271277

272-
User.where(name: "John").david
273-
# SELECT * FROM users WHERE name = 'John' AND name = 'David'
278+
```ruby
279+
User.where(name: "John").david
280+
# SELECT * FROM users WHERE name = 'John' AND name = 'David'
281+
```
274282

275283
After:
276284

277-
User.where(name: "John").david
278-
# SELECT * FROM users WHERE name = 'David'
285+
```ruby
286+
User.where(name: "John").david
287+
# SELECT * FROM users WHERE name = 'David'
288+
```
279289

280290
* `where.not` now generates NAND predicates instead of NOR.
281291

282292
Before:
283293

284-
User.where.not(name: "Jon", role: "admin")
285-
# SELECT * FROM users WHERE name != 'Jon' AND role != 'admin'
294+
```ruby
295+
User.where.not(name: "Jon", role: "admin")
296+
# SELECT * FROM users WHERE name != 'Jon' AND role != 'admin'
297+
```
286298

287299
After:
288300

289-
User.where.not(name: "Jon", role: "admin")
290-
# SELECT * FROM users WHERE NOT (name == 'Jon' AND role == 'admin')
301+
```ruby
302+
User.where.not(name: "Jon", role: "admin")
303+
# SELECT * FROM users WHERE NOT (name == 'Jon' AND role == 'admin')
304+
```
291305

292306
* To use the new per-database connection handling applications must change
293307
`legacy_connection_handling` to false and remove deprecated accessors on

guides/source/action_mailer_basics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ config.asset_host = 'http://example.com'
628628

629629
Now you can display an image inside your email.
630630

631-
```ruby
631+
```html+erb
632632
<%= image_tag 'image.jpg' %>
633633
```
634634

guides/source/active_record_validations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ class Person < ApplicationRecord
11771177
end
11781178
```
11791179

1180-
```irb>
1180+
```irb
11811181
irb> person = Person.new(name: "John Doe")
11821182
irb> person.valid?
11831183
=> true
@@ -1357,7 +1357,7 @@ it generates that displays the full list of errors on that model.
13571357
Assuming we have a model that's been saved in an instance variable named
13581358
`@article`, it looks like this:
13591359

1360-
```ruby
1360+
```html+erb
13611361
<% if @article.errors.any? %>
13621362
<div id="error_explanation">
13631363
<h2><%= pluralize(@article.errors.count, "error") %> prohibited this article from being saved:</h2>

guides/source/association_basics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2183,7 +2183,7 @@ The [`collection.clear`][] method removes every object from the collection by de
21832183

21842184
The [`collection.empty?`][] method returns `true` if the collection does not contain any associated objects.
21852185

2186-
```ruby
2186+
```html+erb
21872187
<% if @part.assemblies.empty? %>
21882188
This part is not used in any assemblies
21892189
<% end %>

guides/source/engines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ not your engine's application controller. Ruby is able to resolve the `Applicati
244244
The best way to prevent this from happening is to use `require_dependency` to ensure that the engine's application
245245
controller is loaded. For example:
246246

247-
``` ruby
247+
```ruby
248248
# app/controllers/blorgh/articles_controller.rb:
249249
require_dependency "blorgh/application_controller"
250250

guides/source/generators.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,13 @@ escaped so that the generated output is valid ERB code.
361361
For example, the following escaped ERB tag would be needed in the template
362362
(note the extra `%`)...
363363

364-
```ruby
364+
```erb
365365
<%%= stylesheet_include_tag :application %>
366366
```
367367

368368
...to generate the following output:
369369

370-
```ruby
370+
```erb
371371
<%= stylesheet_include_tag :application %>
372372
```
373373

guides/source/layouts_and_rendering.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,13 +1089,13 @@ Partial templates - usually just called "partials" - are another device for brea
10891089
10901090
To render a partial as part of a view, you use the [`render`][view.render] method within the view:
10911091
1092-
```ruby
1092+
```html+erb
10931093
<%= render "menu" %>
10941094
```
10951095
10961096
This will render a file named `_menu.html.erb` at that point within the view being rendered. Note the leading underscore character: partials are named with a leading underscore to distinguish them from regular views, even though they are referred to without the underscore. This holds true even when you're pulling in a partial from another folder:
10971097

1098-
```ruby
1098+
```html+erb
10991099
<%= render "shared/menu" %>
11001100
```
11011101

guides/source/routing.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ Both the `matches?` method and the lambda gets the `request` object as an argume
780780

781781
You can specify constraints in a block form. This is useful for when you need to apply the same rule to several routes. For example
782782

783-
```
783+
```ruby
784784
class RestrictedListConstraint
785785
# ...Same as the example above
786786
end
@@ -795,7 +795,7 @@ end
795795

796796
You also use a `lambda`:
797797

798-
```
798+
```ruby
799799
Rails.application.routes.draw do
800800
constraints(lambda { |request| RestrictedList.retrieve_ips.include?(request.remote_ip) }) do
801801
get '*path', to: 'restricted_list#index',
@@ -967,13 +967,13 @@ end
967967

968968
The [`resolve`][] method allows customizing polymorphic mapping of models. For example:
969969

970-
``` ruby
970+
```ruby
971971
resource :basket
972972

973973
resolve("Basket") { [:basket] }
974974
```
975975

976-
``` erb
976+
```erb
977977
<%= form_with model: @basket do |form| %>
978978
<!-- basket form -->
979979
<% end %>

guides/source/upgrading_ruby_on_rails.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,9 @@ warning about this upcoming change.
719719
When you are ready, you can opt into the new behavior and remove the deprecation
720720
warning by adding the following configuration to your `config/application.rb`:
721721

722-
ActiveSupport.halt_callback_chains_on_return_false = false
722+
```ruby
723+
ActiveSupport.halt_callback_chains_on_return_false = false
724+
```
723725

724726
Note that this option will not affect Active Support callbacks since they never
725727
halted the chain when any value was returned.
@@ -811,7 +813,9 @@ parameters are already permitted, then you will not need to make any changes. If
811813
and other methods that depend on being able to read the hash regardless of `permitted?` you will
812814
need to upgrade your application to first permit and then convert to a hash.
813815

814-
params.permit([:proceed_to, :return_to]).to_h
816+
```ruby
817+
params.permit([:proceed_to, :return_to]).to_h
818+
```
815819

816820
### `protect_from_forgery` Now Defaults to `prepend: false`
817821

@@ -915,7 +919,9 @@ This can be turned off per-association with `optional: true`.
915919
This default will be automatically configured in new applications. If an existing application
916920
wants to add this feature it will need to be turned on in an initializer:
917921

918-
config.active_record.belongs_to_required_by_default = true
922+
```ruby
923+
config.active_record.belongs_to_required_by_default = true
924+
```
919925

920926
The configuration is by default global for all your models, but you can
921927
override it on a per model basis. This should help you migrate all your models to have their
@@ -943,48 +949,62 @@ Rails 5 now supports per-form CSRF tokens to mitigate against code-injection att
943949
created by JavaScript. With this option turned on, forms in your application will each have their
944950
own CSRF token that is specific to the action and method for that form.
945951

946-
config.action_controller.per_form_csrf_tokens = true
952+
```ruby
953+
config.action_controller.per_form_csrf_tokens = true
954+
```
947955

948956
#### Forgery Protection with Origin Check
949957

950958
You can now configure your application to check if the HTTP `Origin` header should be checked
951959
against the site's origin as an additional CSRF defense. Set the following in your config to
952960
true:
953961

954-
config.action_controller.forgery_protection_origin_check = true
962+
```ruby
963+
config.action_controller.forgery_protection_origin_check = true
964+
```
955965

956966
#### Allow Configuration of Action Mailer Queue Name
957967

958968
The default mailer queue name is `mailers`. This configuration option allows you to globally change
959969
the queue name. Set the following in your config:
960970

961-
config.action_mailer.deliver_later_queue_name = :new_queue_name
971+
```ruby
972+
config.action_mailer.deliver_later_queue_name = :new_queue_name
973+
```
962974

963975
#### Support Fragment Caching in Action Mailer Views
964976

965977
Set `config.action_mailer.perform_caching` in your config to determine whether your Action Mailer views
966978
should support caching.
967979

968-
config.action_mailer.perform_caching = true
980+
```ruby
981+
config.action_mailer.perform_caching = true
982+
```
969983

970984
#### Configure the Output of `db:structure:dump`
971985

972986
If you're using `schema_search_path` or other PostgreSQL extensions, you can control how the schema is
973987
dumped. Set to `:all` to generate all dumps, or to `:schema_search_path` to generate from schema search path.
974988

975-
config.active_record.dump_schemas = :all
989+
```ruby
990+
config.active_record.dump_schemas = :all
991+
```
976992

977993
#### Configure SSL Options to Enable HSTS with Subdomains
978994

979995
Set the following in your config to enable HSTS when using subdomains:
980996

981-
config.ssl_options = { hsts: { subdomains: true } }
997+
```ruby
998+
config.ssl_options = { hsts: { subdomains: true } }
999+
```
9821000

9831001
#### Preserve Timezone of the Receiver
9841002

9851003
When using Ruby 2.4, you can preserve the timezone of the receiver when calling `to_time`.
9861004

987-
ActiveSupport.to_time_preserves_timezone = false
1005+
```ruby
1006+
ActiveSupport.to_time_preserves_timezone = false
1007+
```
9881008

9891009
### Changes with JSON/JSONB serialization
9901010

@@ -1051,7 +1071,9 @@ you are ready, you can opt into the new behavior and remove the
10511071
deprecation warning by adding following configuration to your
10521072
`config/application.rb`:
10531073

1054-
config.active_record.raise_in_transactional_callbacks = true
1074+
```ruby
1075+
config.active_record.raise_in_transactional_callbacks = true
1076+
```
10551077

10561078
See [#14488](https://github.com/rails/rails/pull/14488) and
10571079
[#16537](https://github.com/rails/rails/pull/16537) for more details.

0 commit comments

Comments
 (0)