I am a newbie in Rails. I created a controller and a action. In the corresponding view I used
<%= puts “asd” %> once and <%= p “asd” %> the other time.
In case id puts it shows on the console and in case of p it is rendered as HTML. What is the possible reason?
putscalls the methodto_spcalls the methodinspectSemantically, to_s is meant to output the representation of the object to the user, and inspect to hint about the internal properties of the object (kinda like python’s
repr), but that’s just a convention.If you want to inspect something in your HTML use
<%= debug "something" %>