Skip to content
This repository has been archived by the owner. It is now read-only.

Give HTML format priority over atom in respond_to #23

Merged
merged 1 commit into from Feb 9, 2016
Merged

Conversation

@fofr
Copy link
Contributor

@fofr fofr commented Feb 9, 2016

If a browser sends an unspecific accepts header, eg */*, Rails falls through to the first format/variant declared in respond_to.

Giving the HTML variant priority makes sure that gets rendered first. This was affecting IE8 and below.

Fixes #22

@fofr
Copy link
Contributor Author

@fofr fofr commented Feb 9, 2016

Closing while I add a test to avoid future regressions.

@fofr fofr closed this Feb 9, 2016
If a browser sends an unspecific accepts header, eg `*/*`, Rails falls
through to the first format/variant declared in `respond_to`.

Giving the HTML variant priority makes sure that gets rendered first.
This was affecting IE8 and below.

Fixes #22
@fofr fofr reopened this Feb 9, 2016
@fofr fofr force-pushed the fix-ie-xml-bug branch from b62616e to c5d384b Feb 9, 2016
tuzz added a commit that referenced this pull request Feb 9, 2016
Give HTML format priority over atom in respond_to
@tuzz tuzz merged commit ed84e90 into master Feb 9, 2016
1 check passed
1 check passed
default Build #80 succeeded on Jenkins
Details
@tuzz tuzz deleted the fix-ie-xml-bug branch Feb 9, 2016
@tuzz
Copy link
Contributor

@tuzz tuzz commented Feb 9, 2016

👍

@jamiecobbett
Copy link

@jamiecobbett jamiecobbett commented Feb 10, 2016

If a browser sends an unspecific accepts header, eg /, Rails falls through to the first format/variant declared in respond_to.

Now that is something to remember.

fofr added a commit to alphagov/government-frontend that referenced this pull request Aug 14, 2017
When a request is made for an unsupported format, eg text/javascript,
the lack of a respond_to block meant we attempted to render it without
a layout.

This led to a body being sent to slimmer without a #wrapper element,
causing the error:
`> undefined method `to_html' for nil:NilClass` in the BodyInserter
processor

* Add a respond_to block to respond only to known formats
* Catch unknown format errors and return 406 (not acceptable)

This matches: alphagov/finder-frontend#271

`format.html` must come before `format.atom` in the block. If a browser
sends an unspecific accepts header, eg `*/*`,
Rails falls through to the first format/variant declared in `respond_to`.

See also: alphagov/multipage-frontend#23
fofr added a commit to alphagov/government-frontend that referenced this pull request Aug 14, 2017
When a request is made for an unsupported format, eg text/javascript,
the lack of a respond_to block meant we attempted to render it without
a layout.

This led to a body being sent to slimmer without a #wrapper element,
causing the error:
`> undefined method `to_html' for nil:NilClass` in the BodyInserter
processor

* Add a respond_to block to respond only to known formats
* Catch unknown format errors and return 406 (not acceptable)

This matches: alphagov/finder-frontend#271

`format.html` must come before `format.atom` in the block. If a browser
sends an unspecific accepts header, eg `*/*`,
Rails falls through to the first format/variant declared in `respond_to`.

See also: alphagov/multipage-frontend#23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.