ruby-on-railsruby-on-rails-4pry-rails

How to hide a column in pry / rails output


I have an image blob written to a field in the db, but I don't want to see that output in a console when I view the user object.

I don't need the output changed or modified for the functioning of the application this is JUST for debugging / developing with the console. I did attempt some of the serialization concepts but they aren't helpful for these purposes. I also looked into filter_parameters which only are helpful for logging and not pry console output.

I am using the pry-rails gem for the rails console, if that changes anything.


Solution

  • Maybe a bit late to the party, but in current versions of ActiveRecord, the cleanest solution would be to overwrite attribute_for_inspect, e.g.

    def attribute_for_inspect(attr_name)
      return 'SKIPPED' if attr_name == :blob
    
      super
    end