forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
because it does not feel friendly that the name of the class is mentioned in one of error messages, while its documentation is rendered private. Also edit the error message in order to navigate those who read first to the higher-level module, `ActiveStorage::SetCurrent`. Closes rails#52219
- Loading branch information
Showing
4 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
activestorage/app/controllers/concerns/active_storage/set_current.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
class ActiveStorage::Current < ActiveSupport::CurrentAttributes # :nodoc: | ||
# = Active Storage \Current | ||
# | ||
# Disk service for development and testing is a special case | ||
# as it requires protocol, host and port specified additionally | ||
# in order to generate url, which non-disk services can usually dispense with. | ||
# | ||
# Use ActiveStorage::SetCurrent to effectively test the custom controllers' behavior | ||
# to generate url no matter what type of service underlies the storage. | ||
# | ||
# class UsersController < ApplicationController | ||
# include ActiveStorage::SetCurrent | ||
# | ||
# def show | ||
# @user = User.find(params[:id]) | ||
# @url = @user.profile.url | ||
# end | ||
# end | ||
# | ||
# If including the module like above does not help because, for example, | ||
# controllers do not participate in generating url, use Current.url_options= but with caution. | ||
# Knowing the nature of ActiveSupport::CurrentAttributes would be of help. | ||
class ActiveStorage::Current < ActiveSupport::CurrentAttributes | ||
## | ||
# :singleton-method: url_options | ||
# | ||
# Returns the options for the current request. | ||
|
||
## | ||
# :singleton-method: url_options= | ||
# :call-seq: url_options=(options) | ||
# | ||
# Sets the options for the current request. | ||
# For the supported options, see ActionDispatch::Routing::UrlFor#url_for. | ||
|
||
attribute :url_options | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters