简体   繁体   中英

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.

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.

Yes this will return you the correct result.

Rails.logger.info(request)

What you have written, that normally returns an array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM