cells icon indicating copy to clipboard operation
cells copied to clipboard

Fix object inspection for cells

Open Startouf opened this issue 9 years ago • 1 comments

During the process of debugging, when I want to check under which context I currently am, I usually write something like self in byebug.

It is fine in most cases, but for cells, this command (which I believe calls the inspect method), by default prints every instance variable, and in the case of a cell this is just disastrous (also printing parent_controller variables, etc.)

We're talking about a HUUUGE string here, printed by mistake in the shell. ie,

self.inspect.size # => 2300182 characters

self

# =>
#<EmployeeCell:0x0000001786a120 @parent_controller=#<SearchesController:0x00000017b80aa8
 @_action_has_layout=true, @_routes=nil, @_request=#
<ActionDispatch::Request:0x00000017dcb150 @env={"rack.version"=>[1, 3], "rack.errors"=>#
<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, 
"SCRIPT_NAME"=>"", "QUERY_STRING"=>"utf8=%E2%9C%93&meeting_type=&q=", 
"SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>....

I would love to have something more useful, but even just writing something like

#<EmployeeCell:0x0000001786a120>

Would actually spare me the "WTF" when writing self while debugging a cell context.

I don't know what kind of information we'd want from that inspect, but showing the cell class, the model's inspect, and the @options would make sense ?

Startouf avatar May 01 '16 13:05 Startouf

Same problem for cell context inspection (new feature in cells 4.1).

cell(:song, song, context: { current_user: current_user })

Trying to debug the context of a cell self.contextis very hard.

Startouf avatar Aug 18 '16 12:08 Startouf