Commit Graph

125 Commits

Author SHA1 Message Date
Jonathan Hefner
3a90f12317 Use appropriate code fences [ci skip]
Follow-up to #39620.

This commit changes a few overlooked code fences to `bash`, and changes
a few IRB session snippets to be only Ruby code with a `ruby` fence.
2020-07-08 14:51:57 -05:00
Eugene Kenny
e6f8bfe1dc Note that insert_all and friends skip callbacks and validations [ci skip] 2020-07-08 12:17:43 +01:00
Juarez Lustosa
44d44777ce [ci skip] Increase info on validate presence for association 2020-06-20 22:02:24 -03:00
Santiago Bartesaghi
0cb67a6307 Documentation: Add touch_all to callbacks and validations guides [ci skip] 2020-06-20 03:30:25 -03:00
Ryuta Kamizono
6a4395f466 Deprecate starts_with? and ends_with? for String core extensions
In the past, we sometimes hit missing `Symbol#start_with?` and
`Symbol#end_with?`.

63256bc5d7
a8e812964d

So I proposed `Symbol#start_with?` and `Symbol#end_with?` to allow duck
typing that methods for String and Symbol, then now it is available in
Ruby 2.7.

https://bugs.ruby-lang.org/issues/16348

Using `String#starts_with?` and `String#ends_with?` could not be gained
that conveniency, so it is preferable to not use these in the future.
2020-05-05 15:51:24 +09:00
cjilbert504
1583d8ee42
active_record_validations.md grammer fix [ci skip]
An extremely small readability change to line 269 [ci skip].
2020-04-15 11:15:50 -05:00
Rafael França
6f6f4e40ab
Merge pull request #36125 from lulalala/doc-for-model-errors
Document update for ActiveModel#errors
2020-04-13 14:11:55 -04:00
Evan Brodie
5b4025b76b Adds default message for :only_integer validation
This adds consistency to the documentation because all other options to the `:numericality` validator have their default error messages mentioned.
2020-03-24 21:39:02 -04:00
lulalala
fcd1e41e82 Document on ActiveModel::Errors changes
Mark private constants

Display alternative for deprecation removal warning

Annotate Error's attributes

More emphasis on adding an error instead of message

Rewrite scaffold template using new errors API

Set first and last with behavior change deprecation

Update more doc and example

Add inspect for easier debugging
2020-01-14 23:55:09 +08:00
Gannon McGibbon
b5c9974fa7 Add ActiveRecord::Validations::NumericalityValidator
Add Active Record numericality validator with support for casting
floats using a database columns' precision value.
2020-01-06 19:01:29 -05:00
Haroon Ahmed
db1ae8cbb4 remove reference to global rails command and replace with bin/rails 2019-12-27 19:32:37 +00:00
Petrik
2e84228d0e Add missing languages for guides code blocks [ci skip]
Some code examples were missing the language used for code highlighting.
2019-12-17 19:38:45 -05:00
Kevin Jacoby
b0743dda8c Clarify documentation by removing charged words
Using words such as 'just', 'simply' and 'easy' implies to the reader
that the tasks they are trying to accomplish are tasks that anyone can
do, which might then frustrate them if they find it difficult to
complete.

This commit rephrases some usage of these words to aid understanding in
the readers without making them feel belittled.

[ci skip]
2019-12-12 19:43:51 +00:00
Nursoltan Saipolda
3ffc3635b9 fix some grammar errors on guide doc. 2019-10-24 15:38:12 +08:00
Louis-Michel Couture
467e79bb8b
Update MySQL links to the current version of the manual [ci skip]
Accessing the MySQL manual without a specific version number will redirect to the latest version of the manual.
Remove non functional id from a comment in favor an explicit message
2019-10-03 20:22:29 -04:00
lulalala
abee034368 Raise deprecation for calling [:f] = 'b' or [:f] << 'b'
Revert some tests to ensure back compatibility
2019-03-31 22:59:12 +08:00
Nathaniel Suchy
d9f1cc05b5 Update links and code examples in the guides to use HTTPS where the host supports it. 2019-03-06 15:21:07 -05:00
Shodai Suzuki
02e6abd8fd Delete documentation inconsistency 'finally' for AR callbacks [ci skip] (#35303) 2019-02-19 13:31:25 +09:00
Gannon McGibbon
27b3b4666c
Merge pull request #34415 from Ana06/present_associations
Clarify the validation of present associations
2018-11-09 14:53:56 -05:00
Ana María Martínez Gómez
e53d2325d5 Clarify the validation of present associations
I think that it is not clear what means that _an association is
present_. Add that it is checking that the foreign key is not empty and
that the referenced object exists to clarify it.
2018-11-09 15:15:09 +01:00
Ryuta Kamizono
7d89337b17
Merge pull request #33348 from ruralocity/update-validation-contexts-guide
Update guide for validation custom contexts [ci skip]
2018-09-28 18:42:09 +09:00
Ana María Martínez Gómez
3cb491f327 Add lambdas in conditional validations
As `Lambdas` are a type of `Proc`, they can also be used in the
`if`/`unless` option of a validation to decide when the validation is
executed. Add this case to the guide for clarification.

Closes https://github.com/rails/rails/issues/33212
2018-08-07 17:35:13 +02:00
Matthew Draper
ec387c6dd9
Merge pull request #33229 from albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails
Prefer rails command over bin/rails
2018-07-25 04:10:29 +09:30
Paul McMahon
7b9c19d94b Rails guides are now served over https
http links will be redirected to the https version, but still better to
just directly link to the https version.
2018-07-24 11:29:31 +09:00
lanzhiheng
29ca7a1e07 Remove the invalid usage document about errors. [ci skip] 2018-07-16 09:53:43 +08:00
Aaron Sumner
4216e93e1a Update guide for validation custom contexts [ci skip]
The Active Record validations guide's section on custom contexts appears
to be incomplete. the code sample shows a context being added to
validations, but not being used.

Add to the sample code for this section by showing validations being run
with and without the custom context. Add a second sample code block
showing that validations with no context are also run, when a context is
used.
2018-07-11 16:22:49 -07:00
Alberto Almagro
40b209db53 Recommend use of rails over bin/rails
As discussed in #33203 rails command already looks for, and runs,
bin/rails if it is present.

We were mixing recommendations within guides and USAGE guidelines,
in some files we recommended using rails, in others bin/rails and
in some cases we even had both options mixed together.
2018-07-06 22:46:35 +02:00
Anthony Crumley
258670244d Added a lot of Oxford commas
[ci skip] A regular expression was used to find a lot of missing Oxford
commas and add them.  The regular expression was as follows.

", ([a-zA-Z0-9.\`:'\"]+ ){1,6}(or|and) "
2018-05-10 12:46:06 -05:00
Yauheni Dakuka
0ce7681686 Fix typos [ci skip] 2018-01-11 00:56:35 +03:00
ohbarye
8779e33a4b Remove obsolete explanation
about passing string to `:if` and `:unless`.
This is a follow up to https://github.com/rails/rails/pull/28058 [ci
skip]
2017-08-17 23:49:49 +09:00
yuuji.yaginuma
b52849d421 Change http postgresql.org links to https [ci skip]
It seems that it accepts only HTTPS connections.
Ref: 7f77cbd996
2017-07-30 21:52:31 +09:00
Joe Francis
7892b717a8 Remove deprecated passing of string to :if/:unless (#29357)
Other examples were removed in 53ff5fc62f9d11b6f60d371df959137f4bf40728

[ci skip]
2017-06-06 02:04:40 +09:30
Philipe Fatio
96c525f250
Remove obsolete warning about regular expression
This warning became obsolete when the regular expression was changed to
use `\z` instead of `\Z` in fce9c4e5e1ecb31cff2ca43a04fbe332816c3c45.

    "-1234\n" =~ /\A[+-]?\d+\Z/ => 0
    "-1234\n" =~ /\A[+-]?\d+\z/ => nil

[ci skip]
2017-03-14 10:57:50 +01:00
yuuji.yaginuma
53ff5fc62f Remove deprecate passing string to :if and :unless conditional options [ci skip]
Follow up to #27608
2017-02-18 10:36:51 +09:00
Tekin Suleyman
b605a6ac9e Correct usage for acceptance validator in guide 2016-08-02 11:24:09 +01:00
schneems
05b7c415c8 [ci skip] Expand information on message options
Link to the more detailed message documentation when using a message option in validations.
2016-06-08 08:59:51 -05:00
Prathamesh Sonpatki
f7d7147ae6
Active Model: Improve CHANGELOG and documentation for validates_acceptance_of [ci skip]
- Improve CHANGELOG entry for #18439.
- The documentation is updated as per changes in PR #18439 to the
  `accept` option.
- The explanation about the virtual attribute is moved at the end so
  that the arity of `accept` option is explained first.
- Added a note that `message` can also be passed to `validates_acceptance_of`.
2016-05-05 16:25:47 -05:00
Prathamesh Sonpatki
7f1fc1ee09
Update example of passing a proc to :message option for validating records [ci skip]
- This change is made as the behavior for `:message` proc was changed in
  https://github.com/rails/rails/pull/24119.
- Also check
  https://github.com/rails/rails/pull/24431#issuecomment-206106790 for
  reference.
2016-04-06 09:29:01 +05:30
Arthur Vieira
723a7c8ef4 [ci skip] Fix variable name 2016-04-04 18:17:04 -03:00
Arkadiusz Fal
ee640a1f75 [skip ci] Update numericality validation docs
Add `:other_than` option documentation.
2016-03-28 12:22:46 +02:00
Vijay Kumar Agrawal
e6aaa8570a [ci skip] Added missing custom context validation 2016-03-24 19:56:04 +05:30
Mehmet Emin İNAÇ
804b4092e8 Fix small typo in Rails guides [ci skip] 2016-02-15 16:09:11 +02:00
Genadi Samokovarov
2067fff9e3 Introduce ApplicationRecord, an Active Record layer supertype
It's pretty common for folks to monkey patch `ActiveRecord::Base` to
work around an issue or introduce extra functionality. Instead of
shoving even more stuff in `ActiveRecord::Base`, `ApplicationRecord` can
hold all those custom work the apps may need.

Now, we don't wanna encourage all of the application models to inherit
from `ActiveRecord::Base`, but we can encourage all the models that do,
to inherit from `ApplicationRecord`.

Newly generated applications have `app/models/application_record.rb`
present by default. The model generators are smart enough to recognize
that newly generated models have to inherit from `ApplicationRecord`,
but only if it's present.
2015-12-16 10:30:09 +01:00
Yves Senn
7e6d13420d Merge pull request #22427 from eliotsykes/validation-message-proc-doc
Document message validation option accepts Proc [ci skip]
2015-11-30 10:30:35 +01:00
Eliot Sykes
d16047018f Document message validation option accepts Proc 2015-11-27 16:50:02 +00:00
yuuji.yaginuma
7b679affe0 remove deprecated :tokenizer option from guide [ci skip]
`:tokenizer` option was deprecated in 1c341eb7cbaeb52435f14c2595e391bfb2e5e38b
2015-11-07 22:31:37 +09:00
Sean Griffin
cceaa5c853 Merge pull request #20795 from benjiwheeler/validation_guide_ret_val
activerecord guide: clarified roles of valid method and errors object [ci skip]
2015-10-20 15:50:25 -06:00
amitkumarsuroliya
ccbf1597b7 Replace #=> with # => [ci skip]
@rafaelfranca suggested in f7c7bcd9c2 that code examples should display
the result after  `# =>` and not after `#=>`.
2015-09-19 13:45:13 +05:30
Arthur Nogueira Neves
29886d9304 Merge pull request #20897 from lukechesser/guide-fix-for-acceptance-validation
Update Validation guide for acceptance method
2015-09-14 21:18:19 -04:00
amitkumarsuroliya
08c0ef777f Updated MySQL documentation link to MySQL latest version 5.7 everywhere [ci skip]
Bumps from `5.6` to `5.7`
2015-09-10 07:38:18 +05:30