Puts not working

hi,

in my book it says that i can output things with “puts”
but where will the output appear - i cant find it anywhere?

thanks for any tip
andreas

Andreas S. wrote:

hi,

in my book it says that i can output things with “puts”
but where will the output appear - i cant find it anywhere?

thanks for any tip
andreas

It depends how your are running your rails application. If you are using
script/server, the puts will output in the server output (in the
console) when you access a page. Some setups will crash if they see a
“puts” in your code.

It sounds like you are trying to do some debugging with these print
statements … I suggest using breakpointer … simply put a call to
“breakpoint” in your code where you want to break, and start
script/breakpointer in a new shell … this will give you an irb console
to your rails application at the breakpoint.

James Schementi wrote:

Andreas S. wrote:

hi,

in my book it says that i can output things with “puts”
but where will the output appear - i cant find it anywhere?

thanks for any tip
andreas

It depends how your are running your rails application. If you are using
script/server, the puts will output in the server output (in the
console) when you access a page. Some setups will crash if they see a
“puts” in your code.

It sounds like you are trying to do some debugging with these print
statements … I suggest using breakpointer … simply put a call to
“breakpoint” in your code where you want to break, and start
script/breakpointer in a new shell … this will give you an irb console
to your rails application at the breakpoint.

mhhh seams not that easy…

$ ruby script/breakpointer
/usr/local/lib/ruby/1.8/drb/drb.rb:837:in getaddrinfo': getaddrinfo: No address associated with nodename (SocketError) from /usr/local/lib/ruby/1.8/drb/drb.rb:837:inopen_server_inaddr_any’
from /usr/local/lib/ruby/1.8/drb/drb.rb:860:in open_server' from /usr/local/lib/ruby/1.8/drb/drb.rb:756:inopen_server’
from /usr/local/lib/ruby/1.8/drb/drb.rb:754:in open_server' from /usr/local/lib/ruby/1.8/drb/drb.rb:1336:ininitialize’
from /usr/local/lib/ruby/1.8/drb/drb.rb:1624:in start_service' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/breakpoint_client.rb:146 from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/breakpoint_client.rb:145 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
require' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/breakpointer.rb:1 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require’
from script/breakpointer:3

Andreas,

puts is for console output. It won’t print anything to a page in Rails.
You use it in ruby scripts executed from the console.
In Rails, all rendering is done in the .rhtml files, so anything that
needs to be output-ted has to be in there.

Jason

Andreas S. wrote:

hi,

in my book it says that i can output things with “puts”
but where will the output appear - i cant find it anywhere?

My best advice is don’t use puts in Rails code. It leads to application
errors, at least in Apache/FCGI.

Use logger.info “whatever you want”. It will show up in your
development.log or production.log, depending on you RAILS_ENV.

–Al Evans–

puts will output smthg in your console if you have webrick server

i now use mongrel and it doesnt show smthg anymore

On 11/4/06, Jason N. [email protected] wrote:


Heri R.
http://sprinj.com