Skip to content

Commit

Permalink
Update the install generator to set new defaults for new apps
Browse files Browse the repository at this point in the history
We want to change these defaults for all apps eventually, so making sure
new apps are generated with them by default will make this an easier
transation to some in the future.
  • Loading branch information
carlosantoniodasilva committed Jan 27, 2023
1 parent 28f1a98 commit 9efc80b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class ApplicationResponder < ActionController::Responder
end
```

_Note: these defaults may change in a future major release of responders._
_Note_: the application responder generated for new apps already configures a different set of defaults: `422 Unprocessable Entity` for errors, and `303 See Other` for redirects. _Responders may change the defaults to match these in a future major release._

## Examples

Expand Down
2 changes: 2 additions & 0 deletions lib/action_controller/respond_with.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def clear_respond_to
# renders a default action, which is <tt>:new</tt> for a
# +post+ request or <tt>:edit</tt> for +patch+ or +put+,
# and the status is set based on the configured `error_status`.
# (defaults to `422 Unprocessable Entity` on new apps,
# `200 OK` for compatibility reasons on old apps.)
# Thus an example like this -
#
# respond_to :html, :xml
Expand Down
4 changes: 4 additions & 0 deletions lib/generators/responders/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class ApplicationResponder < ActionController::Responder
# Redirects resources to the collection path (index action) instead
# of the resource path (show action) for POST/PUT/DELETE requests.
# include Responders::CollectionResponder
# Configure default status codes for responding to errors and redirects.
self.error_status = :unprocessable_entity
self.redirect_status = :see_other
end
RUBY
end
Expand Down

0 comments on commit 9efc80b

Please sign in to comment.