This site is about programming(mostly) things I either do or am learning.
14 Mar 2015 | | rails
“I would really like to see you..really…”
It’s fairly easy to debug controllers. Use you IDE debugger, or PRY, and set your debug. But how about in views, for example the variables being rendered via ERB or HAML or whatever.
Rails has some helpers you can use: In particular, debug and to_yaml. Just go into your view code and add either(or both of the following)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def use debug
<%= debug @article %>
<p>
<b>Title:</b>
<%= @article.title %>
</p>
end
def use to_yaml
<%= simple_format @article.to_yaml %>
<p>
<b>Title:</b>
<%= @article.title %>
</p>
end