I have an annoying view problem that I'm trying to debug and no where on the Haml Documentation Haml Docs does it specify how to debug view code. This is very annoying and all I need is to debug a variable. Can someone please help me with this? Thank you.
Asked
Active
Viewed 6,783 times
8

Andrey Deineko
- 51,333
- 10
- 112
- 145

Dan Rubio
- 4,709
- 10
- 49
- 106
-
2have you tried `= debug @variable`? – Roman Kiselenko Jan 21 '15 at 17:00
-
I knew it had to be simple! I kept trying - debug @variable. Thanks...... I feel sheepish now. – Dan Rubio Jan 21 '15 at 17:06
3 Answers
9
In Haml, to print a result on the page, you use =
sign, so in your case it is:
= @variable.inspect
To write a conditional statement, for instance if else
, you would use -
:
-if condition
# logic
-else
#logic
Note, there is no end
.

Andrey Deineko
- 51,333
- 10
- 112
- 145
0
I just put debugger as below:
= f.input :hardware_configuration, collection: ['screen', 'screen_and_printer', 'printer_only']
= debugger
and it was there:
6: = f.input :hardware_configuration, collection: ['screen', 'screen_and_printer', 'printer_only']
7: = debugger
(byebug) n
Here you can check whatever variable is there directly(of course which you have declared and assigned in controller).
Note: I have byebug
gem installed.

Mayuresh Srivastava
- 1,332
- 17
- 24