Skip to content

Commit 27786c8

Browse files
Normalize code indentation [ci-skip]
This removes unnecessary indentation of several code snippets, and otherwise normalizes indentation of a handful more.
1 parent 10e0eed commit 27786c8

11 files changed

+109
-106
lines changed

guides/source/active_record_basics.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ that the `products` table was created using an SQL (or one of its extensions) st
147147

148148
```sql
149149
CREATE TABLE products (
150-
id int(11) NOT NULL auto_increment,
151-
name varchar(255),
152-
PRIMARY KEY (id)
150+
id int(11) NOT NULL auto_increment,
151+
name varchar(255),
152+
PRIMARY KEY (id)
153153
);
154154
```
155155

guides/source/active_record_postgresql.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,11 @@ CREATE TYPE full_address AS
218218
```ruby
219219
# db/migrate/20140207133952_create_contacts.rb
220220
execute <<-SQL
221-
CREATE TYPE full_address AS
222-
(
223-
city VARCHAR(90),
224-
street VARCHAR(90)
225-
);
221+
CREATE TYPE full_address AS
222+
(
223+
city VARCHAR(90),
224+
street VARCHAR(90)
225+
);
226226
SQL
227227
create_table :contacts do |t|
228228
t.column :address, :full_address

guides/source/active_record_querying.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,8 @@ WHERE (reviews.created_at > '2019-01-08')
17891789
### Retrieving specific data from multiple tables
17901790

17911791
```ruby
1792-
Book.select('books.id, books.title, authors.first_name')
1792+
Book
1793+
.select('books.id, books.title, authors.first_name')
17931794
.joins(:author)
17941795
.find_by(title: 'Abstraction and Specification in Program Development')
17951796
```
@@ -1800,7 +1801,7 @@ The above should generate:
18001801
SELECT books.id, books.title, authors.first_name
18011802
FROM books
18021803
INNER JOIN authors
1803-
ON authors.id = books.author_id
1804+
ON authors.id = books.author_id
18041805
WHERE books.title = $1 [["title", "Abstraction and Specification in Program Development"]]
18051806
LIMIT 1
18061807
```

guides/source/asset_pipeline.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,9 @@ which contains these lines:
468468

469469
```css
470470
/* ...
471-
*= require_self
472-
*= require_tree .
473-
*/
471+
*= require_self
472+
*= require_tree .
473+
*/
474474
```
475475

476476
Rails creates `app/assets/stylesheets/application.css` regardless of whether the
@@ -501,10 +501,10 @@ might concatenate three CSS files together this way:
501501

502502
```js
503503
/* ...
504-
*= require reset
505-
*= require layout
506-
*= require chrome
507-
*/
504+
*= require reset
505+
*= require layout
506+
*= require chrome
507+
*/
508508
```
509509

510510
### Preprocessing

guides/source/association_basics.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ The `build_association` method returns a new object of the associated type. This
889889

890890
```ruby
891891
@author = @book.build_author(author_number: 123,
892-
author_name: "John Doe")
892+
author_name: "John Doe")
893893
```
894894

895895
##### `create_association(attributes = {})`
@@ -898,7 +898,7 @@ The `create_association` method returns a new object of the associated type. Thi
898898

899899
```ruby
900900
@author = @book.create_author(author_number: 123,
901-
author_name: "John Doe")
901+
author_name: "John Doe")
902902
```
903903

904904
##### `create_association!(attributes = {})`
@@ -1011,7 +1011,7 @@ By convention, Rails assumes that the column used to hold the foreign key on thi
10111011
```ruby
10121012
class Book < ApplicationRecord
10131013
belongs_to :author, class_name: "Patron",
1014-
foreign_key: "patron_id"
1014+
foreign_key: "patron_id"
10151015
end
10161016
```
10171017

@@ -1671,7 +1671,7 @@ The [`collection.build`][] method returns a single or array of new objects of th
16711671

16721672
```ruby
16731673
@book = @author.books.build(published_at: Time.now,
1674-
book_number: "A12345")
1674+
book_number: "A12345")
16751675

16761676
@books = @author.books.build([
16771677
{ published_at: Time.now, book_number: "A12346" },
@@ -1685,7 +1685,7 @@ The [`collection.create`][] method returns a single or array of new objects of t
16851685

16861686
```ruby
16871687
@book = @author.books.create(published_at: Time.now,
1688-
book_number: "A12345")
1688+
book_number: "A12345")
16891689

16901690
@books = @author.books.create([
16911691
{ published_at: Time.now, book_number: "A12346" },
@@ -1878,7 +1878,7 @@ You can also set conditions via a hash:
18781878
```ruby
18791879
class Author < ApplicationRecord
18801880
has_many :confirmed_books, -> { where confirmed: true },
1881-
class_name: "Book"
1881+
class_name: "Book"
18821882
end
18831883
```
18841884

guides/source/caching_with_rails.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,8 @@ response body.
667667
Weak ETags have a leading `W/` to differentiate them from strong ETags.
668668

669669
```
670-
W/"618bbc92e2d35ea1945008b42799b0e7" → Weak ETag
671-
"618bbc92e2d35ea1945008b42799b0e7" → Strong ETag
670+
W/"618bbc92e2d35ea1945008b42799b0e7" → Weak ETag
671+
"618bbc92e2d35ea1945008b42799b0e7" → Strong ETag
672672
```
673673

674674
Unlike weak ETag, strong ETag implies that response should be exactly the same
@@ -677,18 +677,18 @@ large video or PDF file. Some CDNs support only strong ETags, like Akamai.
677677
If you absolutely need to generate a strong ETag, it can be done as follows.
678678

679679
```ruby
680-
class ProductsController < ApplicationController
681-
def show
682-
@product = Product.find(params[:id])
683-
fresh_when last_modified: @product.published_at.utc, strong_etag: @product
684-
end
680+
class ProductsController < ApplicationController
681+
def show
682+
@product = Product.find(params[:id])
683+
fresh_when last_modified: @product.published_at.utc, strong_etag: @product
685684
end
685+
end
686686
```
687687

688688
You can also set the strong ETag directly on the response.
689689

690690
```ruby
691-
response.strong_etag = response.body # => "618bbc92e2d35ea1945008b42799b0e7"
691+
response.strong_etag = response.body # => "618bbc92e2d35ea1945008b42799b0e7"
692692
```
693693

694694
Caching in Development

guides/source/configuring.md

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,72 +1698,73 @@ The key difference between these two is that you should be using `config.x` if y
16981698
are defining _nested_ configuration (ex: `config.x.nested.hi`), and just
16991699
`config` for _single level_ configuration (ex: `config.hello`).
17001700
1701-
```ruby
1702-
config.x.payment_processing.schedule = :daily
1703-
config.x.payment_processing.retries = 3
1704-
config.super_debugger = true
1705-
```
1701+
```ruby
1702+
config.x.payment_processing.schedule = :daily
1703+
config.x.payment_processing.retries = 3
1704+
config.super_debugger = true
1705+
```
17061706
17071707
These configuration points are then available through the configuration object:
17081708
1709-
```ruby
1710-
Rails.configuration.x.payment_processing.schedule # => :daily
1711-
Rails.configuration.x.payment_processing.retries # => 3
1712-
Rails.configuration.x.payment_processing.not_set # => nil
1713-
Rails.configuration.super_debugger # => true
1714-
```
1709+
```ruby
1710+
Rails.configuration.x.payment_processing.schedule # => :daily
1711+
Rails.configuration.x.payment_processing.retries # => 3
1712+
Rails.configuration.x.payment_processing.not_set # => nil
1713+
Rails.configuration.super_debugger # => true
1714+
```
17151715
17161716
You can also use `Rails::Application.config_for` to load whole configuration files:
17171717
1718-
```yaml
1719-
# config/payment.yml
1720-
production:
1721-
environment: production
1722-
merchant_id: production_merchant_id
1723-
public_key: production_public_key
1724-
private_key: production_private_key
1725-
1726-
development:
1727-
environment: sandbox
1728-
merchant_id: development_merchant_id
1729-
public_key: development_public_key
1730-
private_key: development_private_key
1731-
```
1732-
1733-
```ruby
1734-
# config/application.rb
1735-
module MyApp
1736-
class Application < Rails::Application
1737-
config.payment = config_for(:payment)
1738-
end
1718+
```yaml
1719+
# config/payment.yml
1720+
production:
1721+
environment: production
1722+
merchant_id: production_merchant_id
1723+
public_key: production_public_key
1724+
private_key: production_private_key
1725+
1726+
development:
1727+
environment: sandbox
1728+
merchant_id: development_merchant_id
1729+
public_key: development_public_key
1730+
private_key: development_private_key
1731+
```
1732+
1733+
```ruby
1734+
# config/application.rb
1735+
module MyApp
1736+
class Application < Rails::Application
1737+
config.payment = config_for(:payment)
17391738
end
1740-
```
1739+
end
1740+
```
1741+
1742+
```ruby
1743+
Rails.configuration.payment['merchant_id'] # => production_merchant_id or development_merchant_id
1744+
```
17411745
1742-
```ruby
1743-
Rails.configuration.payment['merchant_id'] # => production_merchant_id or development_merchant_id
1744-
```
17451746
`Rails::Application.config_for` supports a `shared` configuration to group common
17461747
configurations. The shared configuration will be merged into the environment
17471748
configuration.
17481749
1749-
```yaml
1750-
# config/example.yml
1751-
shared:
1752-
foo:
1753-
bar:
1754-
baz: 1
1750+
```yaml
1751+
# config/example.yml
1752+
shared:
1753+
foo:
1754+
bar:
1755+
baz: 1
17551756
1756-
development:
1757-
foo:
1758-
bar:
1759-
qux: 2
1760-
```
1757+
development:
1758+
foo:
1759+
bar:
1760+
qux: 2
1761+
```
17611762
17621763
1763-
```ruby
1764-
# development environment
1765-
Rails.application.config_for(:example)[:foo][:bar] #=> { baz: 1, qux: 2 }
1766-
```
1764+
```ruby
1765+
# development environment
1766+
Rails.application.config_for(:example)[:foo][:bar] #=> { baz: 1, qux: 2 }
1767+
```
17671768
17681769
Search Engines Indexing
17691770
-----------------------

guides/source/engines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ Pipeline require statements in processed files:
13411341
```css
13421342
/*
13431343
*= require blorgh/style
1344-
*/
1344+
*/
13451345
```
13461346

13471347
INFO. Remember that in order to use languages like Sass or CoffeeScript, you

guides/source/getting_started.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,10 +1711,10 @@ Concerns are a way to make large controllers or models easier to understand and
17111711

17121712
You can use concerns in your controller or model the same way you would use any module. When you first created your app with `rails new blog`, two folders were created within `app/` along with the rest:
17131713

1714-
```
1715-
app/controllers/concerns
1716-
app/models/concerns
1717-
```
1714+
```
1715+
app/controllers/concerns
1716+
app/models/concerns
1717+
```
17181718

17191719
A given blog article might have various statuses - for instance, it might be visible to everyone (i.e. `public`), or only visible to the author (i.e. `private`). It may also be hidden to all but still retrievable (i.e. `archived`). Comments may similarly be hidden or visible. This could be represented using a `status` column in each model.
17201720

@@ -1938,8 +1938,8 @@ So first, let's add the delete link in the
19381938
19391939
<p>
19401940
<%= link_to 'Destroy Comment', [comment.article, comment],
1941-
method: :delete,
1942-
data: { confirm: "Are you sure?" } %>
1941+
method: :delete,
1942+
data: { confirm: "Are you sure?" } %>
19431943
</p>
19441944
```
19451945

guides/source/i18n.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ NOTE: The backend lazy-loads these translations when a translation is looked up
116116
You can change the default locale as well as configure the translations load paths in `config/application.rb` as follows:
117117

118118
```ruby
119-
config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
120-
config.i18n.default_locale = :de
119+
config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
120+
config.i18n.default_locale = :de
121121
```
122122

123123
The load path must be specified before any translations are looked up. To change the default locale from an initializer instead of `config/application.rb`:
@@ -590,9 +590,8 @@ This way, you can separate model and model attribute names from text inside view
590590
NOTE: The default locale loading mechanism in Rails does not load locale files in nested dictionaries, like we have here. So, for this to work, we must explicitly tell Rails to look further:
591591

592592
```ruby
593-
# config/application.rb
594-
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
595-
593+
# config/application.rb
594+
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
596595
```
597596

598597
Overview of the I18n API Features

0 commit comments

Comments
 (0)