Wie kann ich drucken Sie jedes element eines Arrays wird in einer eigenen Zeile in der Rails-Konsole?

Wenn ich die Rails-Konsole, wie kann ich die Anzeige jedes Element auf einer eigenen Zeile? Statt

> Post.all
=> #<ActiveRecord::Relation [#<Post id: 1, title: "Post #0", comment: nil, link: "http://yahoo.com", user_id: 1, created_at: "2013-09-30 02:29:28", updated_at: "2013-09-30 02:29:28">, #<Post id: 2, title: "Post #1", comment: nil,...

es würde zeigen, wie

> Post.all
=> #<ActiveRecord::Relation [
#<Post id: 1, title: "Post #0", comment: nil, link: "http://yahoo.com", user_id: 1, created_at: "2013-09-30 02:29:28", updated_at: "2013-09-30 02:29:28">, 
#<Post id: 2, title: "Post #1", comment: nil,...

Ähnlich x im Perl-debugger. Ich habe versucht,

Post.alle.each{|e| e.inspect + "\n"}

Aber das machte es nur noch schlimmer, und war nicht sehr bequem war.

Sah ich Ruby on Rails: pretty print für variable.hash_set.inspizieren ... gibt es eine Möglichkeit ganz schön Druck .inpsect in der Konsole? und https://github.com/michaeldv/awesome_print

aber das scheint nicht zu funktionieren

irb(main):005:0> require "awesome_print"
=> false
irb(main):006:0> ap Post.all
#<ActiveRecord::Relation [#<Post id: 1, title: "Post #0",
  • Beachten Sie, dass Post.all nicht gibt ein array zurück, sondern eine ActiveRecord::Relation. Für eine echte Array müssen Sie #to_a.
InformationsquelleAutor Chloe | 2013-12-24
Schreibe einen Kommentar