Skip to content

Shorten inspect on AbstractController::Base and ActionDispatch::Request #39439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Shorten inspect on AbstractController::Base and ActionDispatch::Request #39439

wants to merge 1 commit into from

Conversation

p8
Copy link
Member

@p8 p8 commented May 26, 2020

Calling controller in the debug console generates an endless stream of characters.
This shortens it to only the class name but we can probably add some useful information (action_methods?).

controller.inspect
# => "#<MyController:0x00000000005028>"

Inspect on ActionDispatch::Request is shortened to relevant attributes:

request.inspect
# => "#<ActionDispatch::Request request_method=POST, original_url=https://glu.ttono.us/path/of/some/uri?mapped=1, remote_ip=1.2.3.4, media_type=application/x-www-form-urlencoded>"

@rails-bot rails-bot bot added the actionpack label May 26, 2020
@p8 p8 changed the title Shorten inspect on AbstractController::Base Shorten inspect on AbstractController::Base and ActionDispatch::Request May 26, 2020
@hahmed
Copy link
Contributor

hahmed commented May 28, 2020

Nice work @p8 i really like this change

Copy link
Member

@tenderlove tenderlove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the # on the outside so it looks more like a regular Object#inspect?

$ ruby -e'p Object.new.inspect'
"#<Object:0x00007f979b858df8>"

Thank you for submitting this!

@p8
Copy link
Member Author

p8 commented May 29, 2020

I've also moved the # to the front and created another PR to fix this for other implementations:
#39477 For example for StrongParameters.

@p8 p8 requested a review from tenderlove June 5, 2020 11:05
@rails-bot
Copy link

rails-bot bot commented Sep 3, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@rails-bot rails-bot bot added stale and removed stale labels Sep 3, 2020
Calling controller in the debug console generates an endless stream of
characters.  This shortens it to only the class name but we can probably
add some useful information (action_methods?).

```
controller.inspect
```

Inspect on ActionDispatch::Request is shortened to relevant attributes:
```
request.inspect
```
@p8
Copy link
Member Author

p8 commented Sep 3, 2020

It's probably better to split this in two separate PR's.
I'll split it into one for AbstractController::Base and one for ActionDispatch::Request.

@p8
Copy link
Member Author

p8 commented Sep 3, 2020

I'm closing this to create two separate PR's.

@p8 p8 closed this Sep 3, 2020
@p8 p8 deleted the shorten-inspect-on-controller branch September 3, 2020 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants