Use Awesome Print instead
It is (strangely) intended behavior for large objects.
Don't use pp
from pretty_print
use ap
from awesome_print
문제
Using Rails 4.0.4
and Ruby 2.1.1
, and inside of an model's controller I want to use pp
to check out an object. I have a call to debugger
to pause execution and look around. However, pp
seems to be truncating the out put of things and not allowing them to show up on multiple lines:
>pp ShopOrder
#<Shoporder id: 64, order_id: "142949823232-3232353652342", shop_id: 1, order_
status: "Completed", order_tests_queued: "2014-04-02 18:19:36", shipped_time:
nil, shipping_address_name: "John Doe", total: 43.9, created_time: "2014-04-02
03:04:20", raw: "{\"order_id\":\"142949823232-3232353652342\",\"order_sta...">
( ^^ I did not truncated this for the question, it just ends this way ^^ )
I'm used to pp
normally formatting this nicely and displaying it on multiple lines, more similar to what happens when using y ShopOrder
to get the nicely formatted to_yaml
output:
--- !ruby/object:Shoporder
attributes:
id: 64
order_id: 142949823232-3232353652342
shop_id: 1
order_status: Completed
order_tests_queued: 2014-04-02 18:19:36.498044000 Z
shipped_time:
shipping_address_name: John Doe
total: 43.9
created_time: 2014-04-02 03:04:20.000000000 Z
... (output continues correctly but has been truncated for this example )
Echo is enabled as irb_context.echo
returns true
y
and to_yaml
are fine but at times I'd also like to be able to use pp
Why isn't this working as expected?
해결책 2
It is (strangely) intended behavior for large objects.
Don't use pp
from pretty_print
use ap
from awesome_print
다른 팁
If memory serves pp
relies on a pretty_print
method for its output. Perhaps something is defining that in your models, or overriding it and truncating the string returned by super
.