Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails console truncates the Activerecord output - How to prevent truncating?

I'm trying to get all my user's email from the production rails console. Problem is the emails are being cut off when they are long:

User.select('email').where(:guest => false) 


#<User email: "app+11rmqcgg9q.1d74111.6c2e294218ddadfff033de3f5bb3...">

How can I run the command in rails c and not have rails truncate the output? I just want a CSV of emails.

like image 991
AnApprentice Avatar asked Oct 26 '25 06:10

AnApprentice


2 Answers

It's the output of inspect. So overriding it should be enough. If you care only about the emails in that situation you could actually get it like:

User.where(:guest => false).map(&:email)
like image 138
lucapette Avatar answered Oct 28 '25 21:10

lucapette


puts User.select('email').where(:guest => false).map(&:email).join("\n")
like image 39
iblue Avatar answered Oct 28 '25 19:10

iblue



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!