def new
@story = Story.new(params[:story])
@story.user = @current_user
if request.post? and @story.save
breakpoint
@story.tag_with params[:tags] if params[:tags]
flash[:notice] = 'Story submission succeeded'
redirect_to :action => 'index'
end
end
Now, the new action corresponds with a new story being submitted. As
the author instructs, I opened the web browser and try to submit a
story. The browswer is supposed to hang and I should be able to invoke
the breakpoint client by using the following command:
ruby script/breakpointer
But, the browswer displays the following information instead of hanging:
RuntimeError in StoryController#new
Breakpoints are not currently working with Ruby 1.8.5
RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/vendor/rails/railties/lib/breakpoint.rb:21:in `of_caller'
#{RAILS_ROOT}/vendor/rails/railties/lib/breakpoint.rb:543:in
`breakpoint'
#{RAILS_ROOT}/app/controllers/story_controller.rb:12:in `new'
The breakpoint is indeed, on line 12 of the story_controller.rb file.
This puzzles me! How are people using InstantRails (I am using
InstantRails-1.5-win.zip). I also checked on the Ruby download website
which shows that the current version of Ruby is 1.8.5. Does it mean
that breakpoint functionality is not available in Ruby 1.8.5? Or this
particular release that I am working with does not have it?
Either way, please advise on how to go about solving this problem.
Bharat
--
Posted via http://www.ruby-forum.com/.
I am not sure if this is an Instant Rails problem or something else.
But I am working with Patrick Lenz's Building Your Own Ruby on Rails Web
Applications book where in Chapter 11 he shows how to use the BreakPoint
functionality within an RoR application.  The book demonstrates this
functionality by setting a breakpoint in one of the Controller methods
as follows:
http://www.datanoise.com/articles/2006/07/12/tutorial-on-ruby-debug
I've never tried it on Windows, but it works like a charm on a Mac. If you
do try it and it works on Win32, that would be good to know.
--
View this message in context: http://www.nabble.com/Break-Point-not-working-in-Ruby-1.8.5--tf3450316.html#a9627538
Sent from the RubyOnRails Users mailing list archive at Nabble.com.
I installed this gem using the following command:
gem install c:\ruby-debug-base-0.8.1-mswin32.gem from the InstantRails
command window. Then I put the following line at the end of the
development.rb file which is under config\environments directory.
require 'ruby-debug'
I saved the file and tried to start webrick by running the following
command:
ruby script/server webrick
I get the following stacktrace and the server quits:
C:\InstantRails\rails_apps\shovell-debug-02>ruby script/server webrick
=> Booting WEBrick...
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/commands/servers/webrick.rb:11:
warning: already initialized
constant OPTIONS
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require': no such file to loa
d -- ruby-debug (MissingSourceFile)
from
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
from
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in
`require'
from
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:343:in
`new_constants_i
n'
from
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in
`require'
from
./script/../config/../config/environments/development.rb:22:in
`load_environment'
from
./script/../config/../vendor/rails/railties/lib/initializer.rb:204:in
`load_environment'
from
./script/../config/../vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in
`sil
ence_warnings'
from
./script/../config/../vendor/rails/railties/lib/initializer.rb:201:in
`load_environment'
... 14 levels...
from
./script/../config/../vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in
`require'
from
./script/../config/../vendor/rails/railties/lib/commands/server.rb:39
from script/server:3:in `require'
from script/server:3
Does anyone else has had success installing ruby-debug in Windows
environment? The installation could not be simpler! I can see the
ruby-debug gem installed and gem command lists it as a locally installed
gem. What can be wrong?
# top of file
require 'rubygems' # not sure this is necessary
require 'ruby-debug'
Debugger.start
Then someplace else in your program, put:
debugger
and you'll have a breakpoint. I'd be curious to understand why this is
necessary.
Steve
--
View this message in context: http://www.nabble.com/Break-Point-not-working-in-Ruby-1.8.5--tf3450316.html#a9652789
--steve
--
View this message in context: http://www.nabble.com/Break-Point-not-working-in-Ruby-1.8.5--tf3450316.html#a9661597
1. I had to add: require 'ruby-debug-base' to get this to work
2. my 'debugger' command doesn't make anything happen.
I tried it with and without the require 'rubygems' and that didn't
make any difference.
Any thoughts as to what I'm doing wrong?
Thanks...jon
Also are you doing:
ruby script\server webrick
to get your app running?
To be honest, I don't develop on Windows, so my test was on a hand-built
Ruby/MySQL/Rails install, not instant rails.
--steve
--
View this message in context: http://www.nabble.com/Break-Point-not-working-in-Ruby-1.8.5--tf3450316.html#a9662737
Next, as Steve outlines above, I put the following three statements at
the top of the file.
# top of the story_controller.rb file
require 'rubygems' # not sure this is necessary
require 'ruby-debug'
Debugger.start
Then I put the debugger statement where I wanted the program to stop.
In my case it was in the new method right after the save statement.
Next, I fired up my browser(IE) and posted a new story. You should
notice the browswer to hang. At this point, do not expect a command
window to pop-up. Instead, look at the command window from which you
started the web server. I am using webrick by executing the command:
ruby script/server webrick
I will try it with Mongrel as well later and report my findings.
Look for the ruby debug prompt in the command window from where you
started the web server. Try to issue a simple "list" command to see if
the debugger indeed lists the source. If it works then try to display
the values of instance variables, or params hash using either "p" or
"pp" commands. For example, in my case I did the following:
p @story
or
pp @story
to print the params hash, do a similar command, i.e.
p params
or
pp params
The debugger is very unix/linux like in which no news is good news. I
primarily develop in linux, but there are times when I have to be in
Windows environment and therefore, I was looking to see if ruby and RoR
development is viable in it. I think that the InstantRails team has
done a fabulous job and made ruby and RoR on Windows machine an almost
usable alternative.
Let me know if this helps. Credit goes to Steve though.
Regards,
--steve
--
View this message in context: http://www.nabble.com/Break-Point-not-working-in-Ruby-1.8.5--tf3450316.html#a9663098
Thanks, Steve.... your feedback is much appreciated...jon
--
1. I followed the instructions you and Steve discussed. It failed for me,
but I got it to work by requiring 'ruby-debug-base' instead.
2. The require 'rubygems' is not necessary; I tried it both ways.
3. No browser hang - it just goes about its normal behavior and nothing in
the mongrel window.
I definitely agree with the assessment about InstantRails. I do have some
issues with it, but they are relatively minor at this point. I wish I could
say the same thing about RadRails which I do use, but which is completely
broken for updates. At least what I have seems to be holding together
moderately well.
Thanks again...jon
--
-----Original Message-----
From: rubyonra...@googlegroups.com
[mailto:rubyonra...@googlegroups.com] On Behalf Of Bharat Ruparel
Sent: Sunday, March 25, 2007 11:56 AM
To: rubyonra...@googlegroups.com
Subject: [Rails] Re: Break Point not working in Ruby 1.8.5?
Many Windows editors sense external modifications to files, but seldom do
they put you at the end of the file automagically. Alternatively, just write
a simple "tail" utility in C or Ruby (not very DRY :).
--steve
--
View this message in context: http://www.nabble.com/Break-Point-not-working-in-Ruby-1.8.5--tf3450316.html#a9663329
BTW, I have read the Lenz book as well, along with two other books I am
working on: "Ruby for Rails" (David Black) and "Agile Web Development with
Rails" (Thomas & Hanssen) - both very good.
Re "formatted log viewing" - I don't know if this is what you mean, but I
use vim (Vi Improved - www.vim.org). They have several really nice plugins
for ruby/rails. If you're a vim person (I've used it for many years), then
you'll love this software, and it's free and very well supported.
Cheers...jon
--
-----Original Message-----
From: rubyonra...@googlegroups.com
[mailto:rubyonra...@googlegroups.com] On Behalf Of Bharat Ruparel
Sent: Sunday, March 25, 2007 12:21 PM
To: rubyonra...@googlegroups.com
Subject: [Rails] Re: Break Point not working in Ruby 1.8.5?
Cheers...jon
--
-----Original Message-----
From: rubyonra...@googlegroups.com
[mailto:rubyonra...@googlegroups.com] On Behalf Of s.ross
Sent: Sunday, March 25, 2007 12:01 PM
To: rubyonra...@googlegroups.com
Subject: [Rails] Re: Break Point not working in Ruby 1.8.5?
...jon
--
-----Original Message-----
From: rubyonra...@googlegroups.com
[mailto:rubyonra...@googlegroups.com] On Behalf Of s.ross
Sent: Sunday, March 25, 2007 12:29 PM
To: rubyonra...@googlegroups.com
Subject: [Rails] Re: Break Point not working in Ruby 1.8.5?
Well, it's no substitute for a good command-line shell, but RadRails has
a "tail" function for log files. Just right-click on the log file in the
file navigator and choose "Tail". Also, if you run mongrel (or webrick)
from within RadRails, it puts the mongrel output to a console. So,
stdout (puts) goes to the mongrel output and rails logging (logger) goes
to the console tailing the development.log.
b
[4;36;1mSQL (0.078000) [0m [0;1mSET SQL_AUTO_IS_NULL=0 [0m
[4;35;1mSQL (0.094000) [0m [0mCREATE TABLE schema_info (version
int(11)) [0m
[4;36;1mSQL (0.031000) [0m [0;1mINSERT INTO schema_info (version)
VALUES(0) [0m
[4;35;1mSQL (0.000000) [0m [0mMysql::Error: #42S01Table
'schema_info' already exists: CREATE TABLE schema_info (version
int(11)) [0m
[4;36;1mSQL (0.031000) [0m [0;1mSELECT version FROM
schema_info [0m
Migrating to CreateStories (1)
[4;35;1mSQL (0.000000) [0m [0mMysql::Error: #42S02Unknown table
'stories': DROP TABLE stories [0m
[4;36;1mSQL (0.110000) [0m [0;1mCREATE TABLE stories (`id` int(11)
DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255) DEFAULT
NULL, `link` varchar(255) DEFAULT NULL) ENGINE=InnoDB [0m
Appreciate the help.
C:\>gem in ruby-debug
Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i386-mswin32)
1. ruby-debug 0.8.1 (ruby)
2. ruby-debug 0.8 (ruby)
3. ruby-debug 0.7.5 (mswin32)
4. ruby-debug 0.7.5 (ruby)
5. Skip this gem
6. Cancel installation
> 1
Install required dependency ruby-debug-base? [Yn] y
Select which gem to install for your platform (i386-mswin32)
1. ruby-debug-base 0.8.1 (mswin32)
2. ruby-debug-base 0.8.1 (ruby)
3. Skip this gem
4. Cancel installation
> 1
Successfully installed ruby-debug-0.8.1
Successfully installed ruby-debug-base-0.8.1-mswin32
Installing ri documentation for ruby-debug-0.8.1...
Installing ri documentation for ruby-debug-base-0.8.1-mswin32...
Installing RDoc documentation for ruby-debug-0.8.1...
Installing RDoc documentation for ruby-debug-base-0.8.1-mswin32...
The easiest way of debugging your Rails application is to run it with
rdebug script:
C:\rails-app>rdebug ./script/server
It should work with webrick or mongrel. If you use rdebug script you
don't have to require ruby-debug in your environment.rb file and to
start the debugger with Debugger.start method. Of course, you still
have to set your breakpoints either explicitly using debugger's
'break' command or via Kernel#debugger method.
Kent.
--
Kent
---
http://www.datanoise.com
I am curious as to why the other approach didn't work... any thoughts on
that?
Cheers...jon
--
-----Original Message-----
From: rubyonra...@googlegroups.com
[mailto:rubyonra...@googlegroups.com] On Behalf Of Kent Sibilev
Sent: Sunday, March 25, 2007 9:43 PM
To: rubyonra...@googlegroups.com
Subject: [Rails] Re: Break Point not working in Ruby 1.8.5?
Here's a dump of my log; it doesn't show the coloring and highlighting that
my gvim gives me, so it's much nicer than it looks here. (E.g., the
"DEPRECATION WARNING" is highlighted in red...)
Cheers...jon
Processing AssetController#index (for 10.0.0.152 at 2007-03-25 12:18:26)
[GET]
Session ID: 4cfdd7473a144e83709d3cd9463289f3
Parameters: {"action"=>"index", "controller"=>"asset"}
Redirected to http://edp18:3010/asset/list
Completed in 0.00010 (10000 reqs/sec) | DB: 0.00000 (0%) | 302 Found
[http://edp18/asset]
DEPRECATION WARNING: model is deprecated and will be removed from Rails 2.0
See http://www.rubyonrails.org/deprecation for details. (called from
C:/Dev/INSTAN~1/rails_apps/AssetList/config/../app/controllers/application.r
b:11)
DEPRECATION WARNING: depend_on is deprecated and will be removed from Rails
2.0 See http://www.rubyonrails.org/deprecation for details. (called from
model_without_deprecation at
C:/Dev/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_con
troller/deprecated_dependencies.rb:13)
User Columns (0.015000) SHOW FIELDS FROM users
Processing AssetController#list (for 10.0.0.152 at 2007-03-25 12:18:27)
[GET]
Session ID: 4cfdd7473a144e83709d3cd9463289f3
Parameters: {"action"=>"list", "controller"=>"asset"}
Asset Columns (0.000000) SHOW FIELDS FROM assets
Rendering layoutfalsetemplateajax_scaffold/list.rhtml within layouts/asset
Rendering ajax_scaffold/list.rhtml
Start rendering component ({:action=>"table", :params=>{"action"=>"list",
"controller"=>"asset"}, :controller=>"/asset"}):
--
-----Original Message-----
From: rubyonra...@googlegroups.com
[mailto:rubyonra...@googlegroups.com] On Behalf Of Bharat Ruparel
Sent: Sunday, March 25, 2007 1:40 PM
To: rubyonra...@googlegroups.com
Subject: [Rails] Re: Break Point not working in Ruby 1.8.5?