Commit Graph

127 Commits

Author SHA1 Message Date
André Luis Leal Cardoso Junior
1280620767 Remove legacy media=screen default from stylesheet_link_tag.
If the media attribute is omitted, the default for web browsers is "all", meaning that by default links apply to all media.

Before:

```ruby
> stylesheet_link_tag "style"
=> <link href="/assets/style.css" media="screen" rel="stylesheet" />
```

After:

```ruby
> stylesheet_link_tag "style"
=> <link href="/assets/style.css" rel="stylesheet" />

```

The current behavior is not going to change for existing applications.

For newly built applications, the media attribute is not going to be added by default. Which can be configured using the following:

```
Rails.application.config.action_view.stylesheet_media_default = false
```
2021-01-22 20:42:22 -03:00
Santiago Bartesaghi
e83d7dcb2f Use 4XX instead of 2XX for validation errors responses 2021-01-06 00:10:26 -03: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
Jonathan Hefner
f3f36e7ef7 Fix syntax highlighting [ci-skip]
This fixes the syntax highlighting of several code snippets by changing
the code fences to the correct language.
2020-12-25 21:03:11 -06:00
Jonathan Hefner
384c0d4b2f Fix list item indentation [ci-skip]
This fixes the formatting of list items that include code snippets and
multiple paragraphs.
2020-12-25 13:29:13 -06:00
Jonathan Hefner
cb563a27de Split code snippets by context [ci-skip]
This provides a stronger visual cue that the code in these snippets
belongs in different contexts (e.g. separate files).
2020-12-25 10:53:12 -06:00
Jonathan Hefner
83cfcda3ad Link to API docs in Layouts and Rendering 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.
2020-11-08 21:07:19 -06:00
Joel Hawksley
136b814144 Include layout when rendering objects from controllers
In https://github.com/rails/rails/pull/37919, support
for rendering objects that respond_to render_in in
controllers was added. However, the implementation
did not support layouts.

This change updates the implementation from #37919
to more closely match the rest of the
ActionView::Template classes, enabling the use of layouts.

Co-authored-by: Felipe Sateler <fsateler@gmail.com>
2020-10-14 11:49:45 -06:00
Chirag
84d6a0e568 Formats code blocks for better syntax highlighting 2020-08-21 15:47:32 +05:30
Michael Hagar
b9c05c0fe1 Remove reference to rendering absolute files
Update guides/source/layouts_and_rendering.md

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2020-06-20 10:36:44 -05:00
Michael Hagar
19c6855075
Add comma after however
Not having the comma changes the meaning of the word - from "any way" with no comma, to "but actually" with a comma. It is the latter meaning the guides are intending.
2020-06-18 21:17:52 -05:00
Joel Hawksley
c82a9193df
Document view components support (#38656) 2020-03-13 23:52:49 +01:00
Thais Kusuki
4069282d74 Fix typo in Options for render [ci skip] 2019-11-30 11:34:08 -03:00
Jonathan Hefner
f2cedf9151 Update form examples [ci skip]
Convert examples to use `form_with` instead of `form_for` or `form_tag`,
which have been soft-deprecated.  Also rename form variable in examples
from `f` to `form`, as exemplified by 8ff7ca5d11.
2019-11-01 18:10:36 -05:00
John Hawthorn
9fe5aa32a7 Update guide for render file:
Most of this section was written from the time that render file: was the
default, before CVE-2016-0752.

This updates the guide to the Rails 6 `render file:` behaviour, moves it
to a more appropriate part of the file.

[ci skip]
2019-07-13 21:32:13 -07:00
John Hawthorn
85fa9b6549 Remove obsolete or discouraged render examples
Most of these examples no longer work. The ability to render an absolute
path was removed as part of CVE-2016-0752. In Rails 6 we changed `render
file:` to only take exact paths and always to render them as raw files.
Rendering a template with its extensions _is_ supported, but I don't
think should be recommended.

This also removes `render file:` from an example where it isn't
relevant.

[ci skip]
2019-07-13 21:32:11 -07:00
Saheed Oladele
c8bc3c2943
Fix typo by changing 'for' to 'from' 2019-04-21 08:07:42 +01:00
Edward Rudd
1b645333bc fix typo in the guides (use Rails instead of rails) 2019-04-04 17:58:37 -04:00
Edward Rudd
90a8ce6450 add documentation about variants 2019-04-03 18:10:09 -04: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
Lucas Oliveira
8d5a2c4da1 Update guide for the counter variable when rendering with the as: option
[ci skip]
2018-10-16 20:52:34 -04:00
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
Yong Bakos
1de3c0dd1b Capitalize class name 'Product'.
In this context, the phrase 'product instance' refers to the Product class,
so capitalize it.
2018-06-01 02:41:25 -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
264f4a6b14
Update "Layouts and Rendering in Rails" guide [ci skip]
- Remove mention about `ActionView::TemplateHandlers` since this
    module was removed by c1304098cca8a9247a9ad1461a1a343354650843.
    Change word `subclasses` to `nested classes`.
    See c7408a0e40545558872efb4129fe4bf097c9ce2f
  - Remove useless sentence "Beginning with Rails 2, the standard extensions
    are `.erb` for ERB (HTML with embedded Ruby), and `.builder` for Builder (XML generator)."
2018-01-17 16:31:08 +02:00
Avneet Singh Malhotra
b01cc6663f Correct render method's response header's content type for option(:body) from text/html to text/plain. (#31212) 2017-11-24 13:38:21 +05:30
Rob
0bcfa999b8 Update layouts_and_rendering.md [ci skip] 2017-11-14 13:26:01 +00:00
Neil Matatall
521266f913 Encourage html-safe API in layouts/rendering guide
While the code example was not unsafe, it
encourages the use of confusingly unsafe APIs
(specifically `html_safe`). We have a safe
alternative and we should encourage people to use
it under all circumstances.
2017-09-27 07:14:37 -10:00
Yoshiyuki Hirano
a52e2bed86 Update Layouts and Rendering in Rails [ci skip]
* The example code on this page are similar to ones generated
  by scaffold generator, but some points are different.

* Of course, it is no reason to be as same as scaffolding codes.
  But this is the guide for beginners, I thought it's better
  to be almost same as scaffolding codes.
2017-09-17 07:40:58 +09:00
yuuji.yaginuma
b692955214 Add missing http status codes [ci skip]
Ref: 5401f776f6,
73e08279d4
2017-07-04 12:59:05 +09:00
Jorge Dias
1f48de101b Specify correct extension for text layouts
When using render plain the extension for the layout needs to be .text.erb instead of .txt.erb
2017-06-29 00:16:41 +02:00
Yong Bakos
4d433f8d21 Guides: Clarify partial local variable naming.
Clarify the partial local variable name as being the same as the name
of the partial, minus the _leading_ underscore.
2017-06-23 22:44:55 -07:00
Mike Gunderloy
062e5f2b06
Add :json type to auto_discovery_link_tag
This allows auto_discovery_link_tag to support the JSON Feed standard.
See https://jsonfeed.org/version/1 for more information.
2017-05-20 04:00:13 -05:00
Kasper Timm Hansen
eb4aba0052 [ci skip] Fully qualify missing template error.
Switch extension 👉 format as it's more apt here.
2017-02-11 21:58:36 +01:00
kenta-s
3ea926b86a Add information on :formats option in action_view_overview.md 2017-02-06 21:47:08 +09:00
Matthew Eagar
d9ba3b1e55 Fix typo in guide: _articles should be _article
The guide contains a typo in the "local_assigns" section, where
rendering a model named 'Article' via `render @articles` is shown to
render a partial called `_articles.html.erb`, when in fact the necessary
partial name is `_article.html.erb`
2017-02-03 11:46:08 -05:00
Conrad Beach
b8341b3a2a Fix small typo in Layouts and Rendering guide. [ci skip]
Changed "same way they do" to "same way they are".
2016-11-14 14:07:21 -07:00
Daniel Amireh
b49e601e3a Use local variable instead of instance variable [ci skip]
Update render yield docs to use `search` local variable instead of `@q` instance variable
2016-11-05 14:19:28 +01:00
Vijay Dev
67313650eb Merge branch 'master' of github.com:rails/docrails 2016-09-20 16:27:19 +00:00
Andrey Molchanov
e1252e073a [ci skip] Fixed commas according to Oxford comma in rdoc and guides 2016-09-17 22:36:13 +03:00
Prathamesh Sonpatki
2352fcc162
💅 [ci skip] 2016-09-07 07:33:26 +05:30
Vipul A M
b4dac34508
Document that redirect* don't halt exucution. We explain more on this behavior in 2.3.2, but dont specify that is not halting. Its better to not let developers be caught by surprise. [ci skip] 2016-09-06 23:45:34 +05:30
Rafael Mendonça França
403c57aec0 Update the rendering guide to match the current behavior
In the latest security releases render with a trailing slash no more call
render :file.

Also add a note about the security implications of using it with user
parameters.
2016-03-05 20:07:27 -03:00
Santosh Wadghule
ea36c579c6 Change 'a HTTP' to 'an HTTP' [ci skip] 2016-03-03 20:28:01 +05:30
Ryuta Kamizono
1335959135 Fix grammar a to an [ci skip] 2016-02-13 20:44:44 +09:00
yuuji.yaginuma
9e70daa941 remove description of render :nothing from guide [ci skip]
`:nothing` option was deprecated in 44781b6e9790d90b4f8b9a41d2b2c114b1a582ee
2016-02-09 14:38:50 +09:00
Vipul A M
0764e67863 Make text about render :html option clearer to state, text will get escaped if not marked as safe by using html_safe
Fixes #22648
[ci skip]
2016-01-19 15:15:25 +05:30
Ryo Hashimoto
4f5536068d remove content_tag_for example 2015-12-22 14:51:05 +09:00
Derek Prior
dc4429ca3b
Deprecate redirect_to :back
Applications that use `redirect_to :back` can be forced to 500 by
clients that do not send the HTTP `Referer` (sic) header.
`redirect_back` requires the user to consider this possibility up front
and avoids this trivially-caused application error.
2015-12-16 11:42:25 -05:00
Derek Prior
13fd5586ce
Add redirect_back for safer referrer redirects
`redirect_to :back` is a somewhat common pattern in Rails apps, but it
is not completely safe. There are a number of circumstances where HTTP
referrer information is not available on the request. This happens often
with bot traffic and occasionally to user traffic depending on browser
security settings.

When there is no referrer available on the request, `redirect_to :back`
will raise `ActionController::RedirectBackError`, usually resulting in
an application error.

`redirect_back` takes a required `fallback_location` keyword argument
that specifies the redirect when the referrer information is not
available.  This prevents 500 errors caused by
`ActionController::RedirectBackError`.
2015-12-16 11:42:05 -05:00