1

I want to print a value to string format.

Rails.logger.debug(request)

while am trying to print am getting the output as

#<ActionDispatch::Request:0x45aa2c8>

How can i print this value to string form.

3
  • Use to_s or inspect Commented Jul 11, 2013 at 11:32
  • Rails.logger.debug(request.inspect)??? Commented Jul 11, 2013 at 11:32
  • you probably want .body() to get the content of the request Commented Jul 11, 2013 at 11:32

2 Answers 2

2

You can .inspect the object to output its contents, but keep in mind this object is a class that contains more than just one string. If there is a specific piece of data you are after please add that to your question.

Rails.logger.debug(request.inspect)

ActionDispatch::Request documentation - look here for individual instance methods that may contain the information you're after.

Sign up to request clarification or add additional context in comments.

2 Comments

is there any ways to convert these string to json
0

Yes this will return you the correct result.

Rails.logger.info(request)

What you have written, that normally returns an array.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.