Ruby Gotcha - PP not printing
So I have been studying Ruby and Ruby on Rails since last year — for a change. I am currently creating my first rails application and stumbled on a very confusing problem — I could not print a line in controller!
In cakePHP, debug() function is one of those tools I could not live without because it easily displays string and arrays in formatted HTML. I was looking something similar in rails and I stumbled on pp method. When I tried it in my controller, nothing shows up! Here is my code:
-
def new
-
@meeting = Meeting.new
-
pp params # I'm trying to display the contents of params to check on the content
-
end
I spent a couple of hours googling, checking my environment if I was using the development environment, used puts, echo, print, p and a lot more googling. When I tried to ask for assistance in the ruby user group, I doubled checked my command line where I run the ruby script/server and AHA!! the data are displayed there! This is my first ruby gotcha.
6 Comments
rociiu on January 28th, 2009
install ruby-debug
start your server with ./script/server –debugger
put “debugger” wherever you want , after the server execute to debugger , it will stop them and you can debug in it like in irb (after type irb)
rachel on January 28th, 2009
Thanks @rociiu. I’ll try that one of these days!
jojo siao on February 23rd, 2009
Hi,
I heard news that they will be having a basic tutorials on ruby on rails sponsored by Philippine Ruby Users Group on March. I have to confirm yet, pero I hope you join us!
I want to show you also what already started on building in Ruby on Rails.
rachel on February 23rd, 2009
sure. let me know when pra masched ko. thanks for the info!
jojosiao on March 12th, 2009
March 19, 2009
6:30-9:30
Exist Techbar
5th Floor, Orient Square, Emerald Ave. Ortigas
that’s the sched for this march meetup.
hope you’ll come join us!





neri on January 15th, 2009
hmm.. congrats!?
i don’t know ruby teehee ^^