Debug using Rubymine - ruby-on-rails

I work on RoR application. I would like to debug my app using Rubymine debugger. But I have to run my app on specific port on server. So my question Is. Should I change default port in Rubymine configuration on which webrick run? If so how? Or run app by rubymine? I don't know that are "correct" questions (correct I mean not stupid;)) But I'm fresh in Ruby technologies. Thanks for all answers.
Edit:
dax thank you for your answer I have changed port. Now serwer run but I have in rubymine console information that:
Fast Debugger (ruby-debug-ide 0.4.22, ruby-debug-base19x 0.11.30.pre15) listens on 127.0.0.1:43588
I should change fast debugger port to make it work. Am I right? But I don't have idea how to change it.
Edit:
After a while I get something like this:
30381: Exception in DebugThread loop: wrong number of arguments (0 for 1)
Backtrace:
/home/arkency/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/gems/1.9.1/gems/debugger-1.6.2/lib/ruby-debug/interface.rb:175:in `read_command'
from: /home/arkency/.gem/ruby/1.9.1/gems/ruby-debug-ide-0.4.22/lib/ruby-debug-ide/ide_processor.rb:84:in `process_commands'
from: /home/arkency/.gem/ruby/1.9.1/gems/ruby-debug-ide-0.4.22/lib/ruby-debug-ide.rb:122:in `block in start_control'
[2014-04-13 15:18:08] ERROR SystemExit: exit
/home/arkency/.gem/ruby/1.9.1/gems/ruby-debug-ide-0.4.22/lib/ruby-debug-ide.rb:126:in `exit'
Edit:
I removed debugger gem and now all works fine. Thanks for all replies;)

From my comment: RubyMine doesn't work with debugger gem, so you have to remove it from Gemfile.

You can access/change your server port settings in the edit configurations menu.
see this question for more details

Related

Debugging rails on passenger

I am running a Rails 5 API on passenger locally.
I start the server with passenger start command.
I installed both byebug and pry-rails but none of them are working for me.
I put a debug point, either with byebug or binding.pry, and when the code hits that point it does print the debug point in the server logs, with the code that it is executing but it doesn't actually stop, and I can type but I don't see the results of what I type.
I am starting to believe, based on posts like this one:
https://coderwall.com/p/rtskuw/create-break-points-in-rails-with-passenger-phusion-pry-pry-remote
that I can't actually debug like I debugged on rails s with passenger, but I don't actually want to believe that. There must be an easy way for me to debug the rails code on my passenger terminal without having to open a different terminal to act as a remote client or something like that.
Thank you very much

Wrong number of arguments(1 for 0) on every page, even info

I have created a rails 4.0.0.rc1 project on my desktop pc using Ruby 1.9.3. When I try to run it on my laptop I always get the above exception, no matter which page I request. It even happens on /rails/info/properties. Both computers use the same Ruby and Rails version.
The project still works fine on my desktop PC. I am using a Rubymine development server, I have tried running Rails S in command prompt, but I still get the same error.
I realise this means that I am somehow passing a parameter when I should not be, but I have no idea how I'm doing that. What is going on here?
I have tracked down the gem that seems to be causing this. In this case it seems to be 'Therubyracer' causing this issue for me. For some reason I do not have to include it in my gemfile on my desktop, but my laptop does require it to be included.

How to remote debug a rails 3.0.2

I have a bug in my application which is only happening on 'stage' but not locally. I would like to use a debugger and set a breakpoint so I can debug the application on stage.
Locally I use pry and even got the pry-remote to work locally but couldn't get it to work on the server.
I don't mind using the regular debugger or pry for the debugging.
The problem I am usually hit with:
ArgumentError (non-absolute home)
Thanks.
If you're definitely not putting this out into a production environment while you're testing it, I would recommend the better_errors Gem. It's definitely not for a production site though as it would expose some serious security issues
If you include it in the :development group it will give you a console in the webpage whenever an error is occurring.
If it's not raising a fatal error, then you can throw the raise method anywhere you want to act like a breakpoint, you won't be able to continue on, but it's useful to help do pry like stuff in the webpage.
There's a good guide by Ryan Bates
http://railscasts.com/episodes/402-better-errors-railspanel
One solution to reproduce the error locally is to start your server in the same environment that is failing.
$ RAILS_ENV=staging script/server

How To:Debugging Rails 3.1.x app(Ruby 1.9.3) on Aptana Studio3 in Ubuntu

Is rails debugging supported on Aptana Studio 3. I have earlier debugged Rails applications on Aptana Studio2 with the embedded browser and embedded servers.
1)How to start rails application in Debug Mode?
2)How to enable remote debugging in firefox?
My work environment is as follows and I have been using RVM
Rails 3.1.x
Ruby 1.9.3
Ubuntu 10.10
I have already installed the debug related gems
ruby-debug-base19 (0.11.25)
ruby-debug-ide19 (0.4.12)
Try removing (commenting out) ruby-debug-base19 from Gemfile. "ruby-debug-ide" should be enough, judging from the comments from a post on different IDE - RubyMine.
For debugging, right click on the project and select "Server Debug", then open the site manually in firefox (you will see the address/port the server listening to in the console). I did not manage to set a breakpoint this way, but I only had a test project with no logic in it, so I am not sure how well it works on a real project.
Not sure about your question on "remote debugging with Firefox".
Answer for Q1: Aptana is just an IDE which provides you a not bad interface to input code. I don't think it a very good idea to 'DEBUG' in it.
For me, debugging rails depends on : command line, unit tets and log files. you should first of all, write an failed unit test, then run it in the command line, and write the implementation code, then run unit test, then write implementation code ... sometimes you need to check the output/log file, finally , the unit tests bar turns to green and your code is implemented.
hope this post useful to you:
How to configure aptana for instant running of my script
Answer for Q2: I don't know your "remote debugging in firefox". If you want to show detailed error message to someone else, just start your server as "development" mode. e.g.
rails s -p 3000 -e development
or just:
rails s

How do I use ruby-debug in Capybara w/ selenium

We have Capybara working with the selenium driver but when I try to use 'debugger' inside a step it doesn't quite work.
e.g. in the debug console entering 'page' works but entering 'page.body' hangs.
We also had weirdness when trying to use debugger with the akephalos driver. With akephalos we couldn't type in the debug prompt... well actually we could but you had to hit the key several times before a letter would randomly show up in the terminal. Doing a 'Ctrl-C' let us type but we got errors like 'DRb connection ...something' (sorry don't have the exact error anymore).
I think the problem is that drivers like selenium and akephalos run the tests and a server in the same process and it confuses ruby-debug. I'm going to try running the server separately (script/server test) and use Capybara.app_host = 'http://localhost:3000' to see if that will make a difference. I tried that with akephalos but didn't get anywhere since it just launched another in-process server anyway.
Is there anyone out there using ruby-debug with Capybara and selenium? Is this working for anyone else? Am I missing something obvious?
Setting Capybara.app_host = 'http://localhost:3000' and running script/server -e test in another process worked.
I don't have a real answer myself, but your question reminded me of this post:
Selenium doesn't work with Cucumber/Capybara (out of the box) - MacOSX
Where the questioner shows how he used ruby-debug to figure out why a missing dependency was helping selenium fail to open the browser.
Hope this helps!
I found this works (in the cucumber env.rb file)
Capybara.default_wait_time = 2000 #default: 2

Resources