Commit Graph

193 Commits

Author SHA1 Message Date
Missy Davies
d49a3abc01 Capitalize headings to match style guidelines
Fix all headings to follow Rails Guides Guidelines
2022-10-17 17:01:28 -10:00
Tony Drake
d6715c72c5 Scaffold destroy action returns status code 303
The default controller scaffolding currently sends back a 302 for its
destroy action.

Since Hotwire is the default for Rails going forward, this can be
problimatic. Turbo uses the fetch API internally which is particular on
how it handles redirects.

As outlined in this table in this Turbo issue,
https://github.com/hotwired/turbo/issues/84#issuecomment-862656931,
Turbo making a DELETE request (not POST + hidden _method field) and
recieving a 302 back will result in another DELETE request instead of a
GET request for the redirect.

This updates the controller template used for the scaffold generator
to send back the 303 see other status code for the destroy action.

For consistancy-sake, the Action Controller Overview guide examples
were also updated. The main Getting Started guide page already has
see other used in its example destroy action.

For non-Hotwire users, the browser will still properly redirect on
a 303 as it does with a 302.
2022-10-13 16:08:55 -04:00
Jonathan Hefner
9ac01c6a81 Use relative URLs for intra-guide links [ci-skip]
This ensures that the URLs are properly versioned when the guides are
rendered.
2022-08-05 21:36:18 -05:00
Hartley McGuire
27285e7881
Remove special handling for ActiveRecordStore
activerecord-session_store was removed in 0ffe190, and has been
displaying a special error message when missing since Rails 4.0.

Replace the specific error message so that third party stores get nicer
error handling as well
2022-06-20 00:35:36 -04:00
Jonathan Hefner
c7303ccc31 Link config settings to the configuration guide [ci-skip]
Since #43138, each config setting has its own linkable section in the
configuration guide.

This commit links config settings throughout the guides to their
sections in the configuration guide.
2022-02-13 13:13:11 -06:00
Jonathan Hefner
a84788e117 Add backticks [ci-skip] 2022-02-13 13:07:51 -06:00
Jonathan Hefner
0f3642596f Insert space before opening parenthesis [ci-skip]
Follow-up to #44388.
2022-02-10 12:11:46 -06:00
Petrik
e3beba127b Update parameter filter logging guides [ci-skip]
The `filter_parameters` configuration includes a list of filters in the
latest `filter_parameter_logging` initializer template.
This updates the guides to reflect those changes.
2022-02-10 15:38:25 +01:00
Chris Bloom
0c530467e6 Add note about action names versus ActionController reserved methods
In both Rails 5.2 and Rails 6.1, defining a controller action method
named `config` will result in a `SystemStackError: stack level too deep`
exception for all requests routed to that controller. This is because
`ActiveSupport` defines `ActiveSupport::Configurable#config` which is
included into `ActionController::Base` by default, and the new config
action overrides it. Any actions in the controller will call `render`
which eventually will call `logger` which is a configurable attribute
which calls `config` which then calls the new `config` action which
calls `render` and so on. `config` is not the only method that will
trigger this behavior if redefined in a controller: In Rails 6.1, there
are 17 methods that would result in `SystemStackError` if redefined, 9
that would result in `ArgumentError`, and 3 that would result in a
`AbstractController::DoubleRenderError`. Most of these methods are
obvious that they should be avoided, like `render`, but some, including
`config` since it's never something the user would typically call
themselves and its buried deep down in some dependencies, are surprising
when encountered and the `SystemStackError` that simply points back to
the action method isn't very helpful when trying to debug what has
happened.

This commit updates the ActionController Overview section of the Guide
to add a note about the potential for this conflict, but stops short of
a full list of reserved methods since it's a.) lengthy, and b.) likely
to change as internal APIs are updated.

Closes to https://github.com/rails/rails/issues/41323
2021-06-24 08:23:43 -04:00
Aditya Bhutani
6ad68b62d4 [ci skip] Improved and corrected grammatical errors in Action Controller Overview 2021-06-05 04:54:19 +05:30
John Bampton
7260f79d7a chore: fix grammar and spelling in Markdown and Ruby files 2021-04-15 19:32:27 +10:00
John Bampton
54e526e473 chore: fix grammar, spelling and minor whitespace fix 2021-04-13 21:35:50 +10:00
Jonathan Hefner
cb0da4f817 Fix typos, grammar, and formatting [ci-skip]
This is a collection of minor superficial improvements.  It does not
include any significant content changes.
2020-12-28 12:05:53 -06:00
Petrik
0a583c73c1 Change form_with to generate non remote forms by default
`form_with` would generate a remote form by default.
This confused users because they were forced to handle remote requests.

All new 6.1 applications will generate non-remote forms by default.
When upgrading a 6.0 application you can enable remote forms by default by
setting `config.action_view.form_with_generates_remote_forms` to `true`.
2020-12-01 21:14:37 +01:00
Jonathan Hefner
5dc3955faf Link to API docs in Action Controller guide [ci-skip]
This links the first mention of each method to its API documentation,
similar to a Wikipedia article.  Some subsequent mentions are also
linked, when it suits the surrounding text.

This also modifies the text in a few places to ensure that methods are
explicitly mentioned (and linked) before they appear in code examples.
2020-11-09 17:34:47 -06:00
Vipul A M
d5a0e0faa1
Merge pull request #39736 from mehagar/docs-cookie
Remove reference to deleting sessions via nil [ci-skip]
2020-07-31 08:52:12 +05:30
Vipul A M
2b0f454167
Merge pull request #39738 from mehagar/docs_404
Remove confusing phrase from docs [ci skip]
2020-07-31 08:50:46 +05:30
Michael Hagar
ca878fd2de clarify that you can also set it to nil 2020-07-02 13:56:48 -05:00
Michael Hagar
2c58668c71 rephrase statement 2020-07-02 13:52:53 -05:00
Vipul A M
f485a0da29
Merge pull request #39737 from mehagar/docs-style
Improve docs sentence structure [ci-skip]
2020-06-29 00:18:09 +05:30
Michael Hagar
11a0829e2d improve sentence structure 2020-06-27 14:15:02 -05:00
Michael Hagar
65d49ce18f clarify what is not supposed to be in session 2020-06-27 09:28:22 -05:00
Jonathan Hefner
481035fba0 Use bash code fences and prompts for shell code [ci skip]
Follow-up to #39594, which added CSS in order to select shell commands
sans prompts on triple-click.

This commit adds several bash code fences and prompts where they were
missing, and removes a few where they were inappropriate.
2020-06-13 19:27:30 -05:00
Dylan Clark
db6ce8de4c Remove ForbiddenAttributesError from examples
Examples for flash and session had code that would generally
raise ForbiddenAttributesErrors. Tweak the examples to avoid
this potentially misleading example. [ci skip]
2020-02-27 17:28:37 -08: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
Ryuta Kamizono
868bf88354
Merge pull request #37744 from seejohnrun/around_action-docs
Add guide for inline around_action
2019-12-05 11:38:33 +09:00
Ryuta Kamizono
93e154ac2c Titleize header [ci skip]
Sync style with Basic Authentication and Digest Authentication headers.
2019-11-24 10:07:08 +09:00
soartec-lab
bbcf0be6d8 Update guide missing "HTTP" of "HTTP Token authentication" [skip ci] 2019-11-21 17:34:25 +09:00
John Crepezzi
012b1e3281 Add guide for inline around_action
This commit adds a test to ensure the behavior of inline `around_action`
calls, as well as a change to the guides to call out this alternate use of
`around_action`.

Closes #37616
2019-11-20 12:03:41 -05:00
soartec-lab
61ba095260 Add HTTP Token authentication section to guide [skip ci] 2019-11-13 19:47:48 +09:00
Sharang Dashputre
18504eb78f Use a single term instead of all terms used to describe path and URL helpers together 2019-07-26 23:54:39 +05:30
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
Ryuta Kamizono
713cee01a5 Fix typo a -> an, an -> a [ci skip] 2019-02-11 17:03:10 +09:00
Adam Demirel
4c15ed7753 Update snippet to rails 5 syntax 2018-10-15 15:14:48 +11:00
Mina Slater
f1d647aeff [ci skip] corrects more grammar awkwardness, replacing denylist with restricted list and consistently use permitted 2018-08-22 21:52:17 -05:00
Mina Slater
7bdf43daac [ci skip] fixes awkward grammar 2018-08-22 07:39:26 -05:00
Mina Slater
44da9eb3b9 [ci skip] change all instances of blacklist and whitelist to denylist and allowlist 2018-08-21 21:36:40 -05: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
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
Michael Holroyd
17af429958
Update example for whitelisting arbitrary hashes
Since the ability to whitelist arbitrary hashes was added (https://github.com/rails/rails/issues/9454 was resolved by e86524c0c5), this example is no longer outside of what strong_params can do. Moved this specific example out of the "Outside the Scope" section and into the regular "Examples" section, but left the "Outside the Scope" section as it was since the advice is still relevant for weirder whitelisting situations (maybe someone wants to add a new example that can't be handled natively).
2018-06-14 16:14:47 -04: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
bogdanvlviv
d2fd01ec68
Fix title for example of removing data from session [ci skip]
After #31685 the description says different what
we expect to see in the example. Change `assign that key to be nil` to
`or delete the key/value pair` in order to highlight what is shown in the example.

Fix one more example of removing data from the session in favour of using
`delete` since assigning to `nil` doesn't delete key from it.
2018-04-23 21:59:39 +03:00
Rafael Barbolo
80cbf19453 Remove key from session by using session.delete (#31685)
* Remove key from session by using session.delete

You are not deleting a key from session when you assign nil to that key.

* Update guides on how to destroy a user session

In this commit, the user id is removed from session and controller's variables related to the user are nullified.

[Rafael Mendonça França + Rafael Barbolo]
2018-04-23 13:50:59 -04:00
Guillermo Iguaran
c680080967
Merge pull request #32277 from derekprior/dp-deprecate-force-ssl
Deprecate controller level force_ssl
2018-03-30 09:02:49 -05:00
Derek Prior
4701a50b58
Deprecate controller level force_ssl
Today there are two common ways for Rails developers to force their
applications to communicate over HTTPS:

* `config.force_ssl` is a setting in environment configurations that
  enables the `ActionDispatch::SSL` middleware. With this middleware
  enabled, all HTTP communication to your application will be redirected
  to HTTPS. The middleware also takes care of other best practices by
  setting HSTS headers, upgrading all cookies to secure only, etc.
* The `force_ssl` controller method redirects HTTP requests to certain
  controllers to HTTPS.

As a consultant, I've seen many applications with misconfigured HTTPS
setups due to developers adding `force_ssl` to `ApplicationController`
and not enabling `config.force_ssl`. With this configuration, many
application requests can be served over HTTP such as assets, requests
that hit mounted engines, etc. In addition, because cookies are not
upgraded to secure only in this configuration and HSTS headers are not
set, it's possible for cookies that are meant to be secure to be sent
over HTTP.

The confusion between these two methods of forcing HTTPS is compounded
by the fact that they share an identical name. This makes finding
documentation on the "right" method confusing.

HTTPS throughout is quickly becomming table stakes for all web sites.
Sites are expected to operate over HTTPS for all communication,
sensitive or otherwise. Let's encourage use of the broader-reaching
`ActionDispatch::SSL` middleware and elminate this source of user
confusion. If, for some reason, applications need to expose certain
endpoints over HTTP they can do so by properly configuring
`config.ssl_options`.
2018-03-30 09:58:28 -04:00
Isaac Orme
2273f5228a Readability fix [ci skip] 2018-03-25 13:02:11 -07:00
Yauheni Dakuka
f1b1494484 Fix note marks [ci skip] 2018-03-12 15:36:26 +03:00
Dixit Patel
ce180231d9 [ci skip] Update MVC wiki link 2017-11-28 16:42:11 +05:30