Skip to content

Commit

Permalink
Restore API documentation example for with_request_url's host param (
Browse files Browse the repository at this point in the history
…ViewComponent#1794)

It looks like this may have been inadvertently deleted in
231d4bb by regenerating the API docs.
That happened because this example was manually added directly in
`api.md` in 5decd07, rather than in the
corresponding YARD comment. To fix this, we've added the example to the
YARD comment and regenerated the API docs.
  • Loading branch information
rmacklin authored and claudiob committed Dec 22, 2023
1 parent 654d896 commit 4845cd2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,14 @@ with_request_url("/users/42") do
end
```

To use a specific host, pass the host param:

```ruby
with_request_url("/users/42", host: "app.example.com") do
render_inline(MyComponent.new)
end
```

### `#with_variant(variant)`

Set the Action Pack request variant for the given block:
Expand Down
8 changes: 8 additions & 0 deletions lib/view_component/test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ def with_controller_class(klass)
# end
# ```
#
# To use a specific host, pass the host param:
#
# ```ruby
# with_request_url("/users/42", host: "app.example.com") do
# render_inline(MyComponent.new)
# end
# ```
#
# @param path [String] The path to set for the current request.
# @param host [String] The host to set for the current request.
def with_request_url(path, host: nil)
Expand Down

0 comments on commit 4845cd2

Please sign in to comment.