Commit Graph

9362 Commits

Author SHA1 Message Date
Xavier Noria
1a9a4b0f51
Merge pull request #52349 from rails/fxn/before_configuration
Improve the docs of before_configuration
2024-07-17 09:17:00 +02:00
Xavier Noria
d12a238502 Improve the docs of before_configuration 2024-07-17 09:14:19 +02:00
Petrik de Heus
d35f52c5d1
Merge pull request #52315 from maniSHarma7575/52310-update-doc-for-active-record-basic-guide
[DOC] Update active record basic guide for create method
2024-07-17 08:12:06 +02:00
David Heinemeier Hansson
3ce3a4e94c
Remove channels from default app/ structure (#52344)
* Remove channels from default app/ structure

Now that Hotwire is the default, the majority of apps won't need custom
channels. And those that do can get the files back via the generator.

* Remove trailing space

* Remove additional needless elements

* No longer to be generated

* No longer generated
2024-07-16 16:55:00 +02:00
Jerome Dalbert
c01a846658
Add script folder and generator (#52335)
Add a new script default folder to hold one-off or general purpose
scripts, such as data migration scripts, cleanup scripts, etc. Also add
a script generator to create such scripts.

Co-authored-by: Haroon Ahmed <haroon.ahmed25@gmail.com>
2024-07-16 12:28:20 +02:00
maniSHarma7575
453577f640 [DOC] Update Active Record basic guide for create method in case of validation fails 2024-07-15 17:35:37 +05:30
Petrik de Heus
4835c94d8a
Merge pull request #51940 from p8/guides/fix-eager-load-examples
Fix query result of eager_load example in the guides. [ci-skip]
2024-07-13 21:23:34 +02:00
yamashun
56072cc1ff Fix markdown table collapse in configuring.md 2024-07-13 18:26:32 +09:00
Andy Croll
6fc58b8eea
Guides CSS to format code tags in h2 headings
Noticed when reading the edge guides that we have some wonky formatting for the case when we use a method name in an h2 heading.

There's already a fix for h3-level headings, so I copied the font-weight (400) and eyeballed a font-size. 2.25rem looked too much to my eyes, so went with 2rem.
2024-07-05 12:12:12 +01:00
Jean Boussier
126445239f
Merge pull request #52274 from Shopify/http-cache
Prefer ETag over Last-Modified for `fresh_when` and `stale?` according to the HTTP specification
2024-07-05 10:27:46 +02:00
heka1024
fc7637103a Prefer ETag over Last-Modified for fresh_when and stale? according to the HTTP specification 2024-07-05 10:18:43 +02:00
Jean Boussier
c79671cc5c
Merge pull request #52254 from ddux/patch-1
[ci skip] Update config/boot.rb contents in initialization.md
2024-07-05 10:00:54 +02:00
Eileen M. Uchitelle
71e14aa7e9
Merge pull request #51735 from heka1024/encryption-compressor
Introduce `compressor` option to `ActiveRecord::Encryption::Encryptor`
2024-07-03 08:39:13 -04:00
heka1024
75421601ce Introduce compressor option to ActiveRecord::Encryption::Encryptor 2024-07-03 18:48:07 +09:00
Xavier Noria
738fde4782
Merge pull request #52251 from rails/fxn/edits
Edits in the dev containers guide
2024-07-02 11:00:04 +02:00
Xavier Noria
47a5d067d6 Edits in the dev containers guide 2024-07-02 10:57:00 +02:00
Dakota Dux
e556176457
Update initialization.md
The code block that contains the code in`config/boot.rb` is missing the line that requires bootsnap/setup.
2024-07-01 22:46:17 -05:00
Will Mathewson
3ae8d7b863
Replace "here" link titles with meaningful titles
For accessibility reasons[1], it's recommended not to use "here"/"click
here"/"more" as the title for a link. When screen reader users are
tabbing through all links on the page, they'll miss the context of "read
more about X" preceding the "here". Thankfully, the sentences in the are
largely good to go, so the "here" can be dropped in favour of the last
part of the sentence to give the link title more meaning.

Some of these text changes may seem trivial, but when considering the
link text outwith its context sentences, the text has some more meaning
for those reading them through screen readers. (e.g. "API documentation"
-> "`number_to_currency` API documentation")

[1]: https://www.gov.uk/guidance/content-design/links#writing-link-text
2024-07-01 20:05:04 +01:00
takmar
ee2c283eb3 Fix broken links in Dev Containers start guide 2024-06-29 20:31:18 +09:00
bhumi1102
f0f624bde4
[RF-DOCS] Action View Form Helpers Guide [ci-skip] (#51936)
In addition to updating the code examples and editing text for clarity and flow, here some more details on some of the changes:

- [X] Do we still need an HTML5 warning at the end of the 1st section? It's pretty standard these days.
--> agree, removed.
- [X] Not sure the output of `_form_with model: @article`_ is 100% correct, might need to double check that.
--> yes. updated this example and got the HTML output from my "guides playground" rails app.
- [X] When we mention `record.persisted?` in record identification, could be a good plug to link to the Active Model guide on that.
--> Hm...there is no direction mention, other than this https://guides.rubyonrails.org/active_model_basics.html#conversion
- [X] Similar to STI, link to the guide / reference on it.
- [X] Time Zone and Country Select should likely be broken into separate sub-sections (I don't mind still mentioning country select)
- [X]  Would the file upload example would be better with a CSV for local processing, rather than showing saving to local disk? (which is probably a very uncommon usage?)
- [X] The _labeled_form_with_ example could likely be simplified with `_**options_` being all that it takes, instead of explicitly showing all possible kwargs.
- [X]  It may be better to show "complex forms" (section 10) right after the parameters (section 8), moving "forms to external resources" down... just because complex forms require exactly the fields_for incantation that was detailed further under the parameters section, so it seems a better continuation. (or potentially even reversed? complex forms then params? not sure)
- [X] Under "complex forms", adding fields on the flow could be slightly expanded, it feels very "go figure". 
--> Yeah, not sure what to do about this one. Was thinking about removing it as there is not built-in support to showcase.

---------

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
Co-authored-by: Petrik de Heus <petrik@deheus.net>
Co-authored-by: Amanda Perino <58528404+AmandaPerino@users.noreply.github.com>
Co-authored-by: Karl Lingiah <karl@superchilled.co.uk>
2024-06-28 17:49:36 +02:00
Rafael Mendonça França
fca2a5e8a6
Merge pull request #51733 from seanpdoyle/document-yield-head
Mention `yield :head` in Guides
2024-06-26 17:03:40 -04:00
Rafael Mendonça França
a1259c7834
Merge pull request #52220 from jcbages/patch-1
[ci skip] Update getting_started.md
2024-06-26 16:59:35 -04:00
Rafael Mendonça França
862f402651
Merge pull request #52209 from bensheldon/strict-local-assigns-defaults
Document undefined `local_assigns` when using Strict Locals with defaults
2024-06-26 16:17:33 -04:00
Rafael Mendonça França
716e4a7d32
Merge pull request #52091 from jasonkim/to-time-use-timezone
Add a config for preserving timezone information when calling `to_time` on TimeWithZone object
2024-06-26 16:16:05 -04:00
Juan Camilo Bages
bcca960d12
Update getting_started.md
- change single quotes to double quotes
- pass article as a local variable instead of instance varialbe in `comments/_form.html.erb`
2024-06-26 02:58:17 -04:00
Louis-Michel Couture
1e4be48f95
Fix guide menu overflow [ci skip]
This is a follow-up to 92b65a0f7e8c07942547d93df4a60a64088ff53f.
It's also a temporary fix until we can find a better solution.
2024-06-25 09:47:26 -04:00
Ben Sheldon [he/him]
fe03a19175
Document undefined local_assigns when using Strict Locals with defaults 2024-06-24 08:25:15 -07:00
Xavier Noria
b448202768 Register 8b173d9 in the guides CHANGELOG 2024-06-20 09:45:25 +02:00
Sampat Badhe
dcadd27cdd
correct table name in schema for add_reference migration in Active Record Migration Documentation [ci skip] 2024-06-20 09:52:52 +05:30
Petrik
8b173d9551 Remove "Migrating from Classic to Zeitwerk" guide [ci-skip]
Rails 7 apps require running in `zeitwerk` mode, so we no longer need
the migration guide. The "Autoloading and Reloading Constants" guide
also handles autoloading with Zeitwerk, including `autoload_paths`, the
`zeitwerk:check` command and more.
2024-06-19 15:27:17 +02:00
Petrik
b06c2c7da0 Move performance section under "Digging Deeper" [ci-skip]
This section was moved to "Advanced Active Record" in
35ad43b1a5b8eaed48588c8045 by accident.
2024-06-19 15:08:47 +02:00
Ridhwana
168b2b369c
[RF-DOCS] Active Record Migration Documentation (#51928)
- [x] We talk about transactions and how to disable them early on, as part of the first few paragraphs, that could be a subsection to add separation.
- [x] The guide goes into reversible early, before even talking about generating migrations and other basic stuff, and then later talks more about it. I think it's important to lay the foundation of change vs up/down, and the fact that migrations should always try to be able to be rolled back, but maybe we can do that without going into reversible that early in the guide, which complicates things further.
- [x] We mention bin/rails generate --help to look for more details, but we could mention specific generators also offer help too, e.g. bin/rails generate model --help or bin/rails generate migration --help
- [x] There's a small section about composite PKs, but there's also [a whole guide on it](https://edgeguides.rubyonrails.org/active_record_composite_primary_keys.html), we can add a link to it from the migrations guide at least for more info on the topic.
- [x] The section that talks about execute shows an example of a specific model Product.connection.execute, but we can call execute directly within a migration, that might be simpler to show.
- [x] We talk about "seed data " in setup & preparing sections, but never mention it before, or explain what seed data is. There's a section about seed data later in the guide, perhaps we can link to it to facilitate.
- [x] In "running specific migrations", bin/rails db:migrate VERSION=zomg actually raises a different error: Invalid format of target version: `VERSION=zomg`... might need a different example there for the unknown migration version error. (no need to show this invalid format one)
- [x] The section about referential integrity can likely be better explained, in particular I think it's worth mentioning that even though the "AR method/way" (the pattern, I mean) doesn't think such "intelligence" belongs to the database, foreign keys and unique indexes are generally safer at the database level. (and should likely have their counterparts explicitly added in code with associations and validations). I just don't want to convey that someone shouldn't be adding FKs & unique constraints, because not adding these can definitely bite you.

Other changes: 
- [x] Moved sections around 
- [x] Added a section about "Rails Migration Version Control"
- [x] Added a section about "Using UUIDs instead of IDs for Primary Keys"

Co-authored-by: bhumi1102 <bhumi1102@gmail.com>
Co-authored-by: Bartosz Łęcki <bart.lecki@gmail.com>
Co-authored-by: Cecile Veneziani <cveneziani@users.noreply.github.com>
Co-authored-by: hatsu <hajiwata0308@gmail.com>
Co-authored-by: Petrik de Heus <petrik@deheus.net>
Co-authored-by: Ahmad hamza  <ahmad.hamza@toptal.com>
Co-authored-by:  Bart de Water <496367+bdewater@users.noreply.github.com>
Co-authored-by: Amanda Perino <58528404+AmandaPerino@users.noreply.github.com>
Co-authored-by: Andy Atkinson <andyatkinson@gmail.com>
Co-authored-by: Jamie Gaskins <jgaskins@gmail.com>
2024-06-19 13:06:58 +02:00
Petrik de Heus
445de23b21
Merge pull request #51533 from p8/guides/advanced-active-record
Move "Advanced Active Record" guides to separate section [ci-skip]
2024-06-16 16:31:09 +02:00
Xavier Noria
ec056dd8fb Document test transactions w/ multiple databases 2024-06-15 13:44:59 +02:00
Sean Doyle
5fa61101c9 Mention yield :head in Guides
Follow up to [#50527][]

Highlight the presence of the `yield :head` pattern established by
`turbo-rails` and adopted by Rails as part of [#50527][].

New applications will generate their application layout with `yield
:head`, so mention that in the documentation.

Also include the `yield :head` call in generated plugin layouts.

[#50527]: https://github.com/rails/rails/pull/50527
2024-06-14 11:16:39 +02:00
Xavier Noria
a1f523bc47 Document transactions in the testing guide 2024-06-14 10:47:56 +02:00
Jason Kim
9dcf17ec4c Add a config for preserving timezone information
when calling `to_time` on TimeWithZone object

Co-authored-by: jhawthorn <jhawthorn@github.com>
2024-06-13 14:56:40 -07:00
fraul
3ba6bc1720
Update the upgrade guides for Rails 7.1 regarding the breaking change (in development/test environments) of the location of secret_key_base (#52083)
Co-authored-by: Felipe <felipe@temporadalivre.com>
2024-06-12 13:15:02 -07:00
Sampat Badhe
53194a442e
Correct typo for Active Record Callbacks doc [ci skip] 2024-06-11 21:46:15 +05:30
Xavier Noria
f64a4134df Define the new start_transaction.active_record event 2024-06-10 17:30:37 +02:00
Bram Janssen
546b6aadbe docs: update list of methods that trigger active record callbacks 2024-06-10 11:19:29 +02:00
Ridhwana
78d655907a
[RF-DOCS] Active Record Callbacks (#51654)
Review and improve Action View Overview guide. [ci-skip]

* Samples that use Proc.new {} can likely be simplified to just use proc {}
* Link to the validations guide where we mention it under conditional callbacks
* after_find callbacks are also triggered by a few other methods: take, sole, find_by!
* We could potentially add some more examples on different types of callbacks that aren't there.
* Updated some sections for clarity

Co-authored-by: Petrik de Heus <petrik@deheus.net>
Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
Co-authored-by: hatsu <hajiwata0308@gmail.com>
2024-06-10 09:18:24 +02:00
yuuji.yaginuma
8c0bbdca09 Fix a value for disabling enqueue_after_transaction_commit [ci-skip]
`enqueue_after_transaction_commit` expects Symbol values, not Boolean.
a472403d55/activejob/lib/active_job/enqueue_after_transaction_commit.rb (L23-L30)
2024-06-09 16:37:21 +09:00
John Athayde
7dbe81710e
Improve RTL Rendering for Guides (#51613)
Improve RTL language support, specifically focused on Arabic (MSA), Farsi, and Hebrew languages, including custom fonts for those languages, a javascript to detect auto-translation and shift the dir attribute, and other cleanup based on volunteer feedback.

Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
2024-06-07 14:00:52 -03:00
Yu Le
25b26cfcb6
Fix typo in active_record_basics.md [skip ci] 2024-06-07 13:27:13 +08:00
Majid Alaeinia
5737cf9ce0
Update association_basics.md 2024-06-05 04:55:01 +03:30
Rafael Mendonça França
f4c39b5e2d
Merge pull request #51994 from matthewd/preserves-timezone-very-deprecated
Re-roll deprecation of to_time_preserves_timezone
2024-06-04 11:02:11 -04:00
Petrik de Heus
5ade5d4173
Merge pull request #50785 from JunichiIto/add-note-to-params-hash
Add note about `params` hash in Action Controller Overview [ci skip]
2024-06-04 14:52:10 +02:00
Xavier Noria
2a5b4fd6cb Add usage guidelines to transaction.active_record docs 2024-06-03 23:22:21 +02:00
Carlos Antonio da Silva
40a52362af
Merge pull request #52004 from duffuniverse/fix-typo-in-active-record-and-postgresql-guide
[ci skip] Fix a typo in Active Record and PostgreSQL guide
2024-06-03 13:31:02 -03:00