divz
divz

Reputation: 7957

Convert to string using Ruby

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.

Upvotes: 1

Views: 201

Answers (2)

Amit
Amit

Reputation: 224

Yes this will return you the correct result.

Rails.logger.info(request)

What you have written, that normally returns an array.

Upvotes: 0

Matt
Matt

Reputation: 14038

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.

Upvotes: 2

Related Questions