I introduce you, how to debug Ruby on Rails Application with Eclipse.
Hi,I’m japanese. So my english ability is poor. Just be patient.
Install Eclipse and JDK
Download JDK from Oracle web site.
Download Eclipse from Eclipse web site.
I install JDK and Eclipse into /usr/java.
[bash]
$ sudo mkdir /usr/java
$ sudo mv ~/Downloads/eclipse-standard-kepler-SR1-linux-gtk.tar.gz /usr/java
$ sudo mv ~/Downloads/jdk-7u51-linux-i586.tar.gz /usr/java/
$ cd /usr/java
$ sudo tar xvzf jdk-7u51-linux-i586.tar.gz
$ sudo tar xvzf eclipse-standard-kepler-SR1-linux-gtk.tar.gz
[/bash]
Setting environment variables
add this settings into ~/.bashrc
[bash]
JAVA_HOME=/usr/java/jdk1.7.0_45
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=$JAVA_HOME/jre/lib/rt.jar
export JAVA_HOME PATH CLASSPATH
[/bash]
refresh environment variables and check JAVA_HOME.
[bash]
$ source ~/.bashrc
$ echo $JAVA_HOME
/usr/java/jdk1.7.0_45
[/bash]
Install Aptana plugin
On Eclipse Menubar, Help > Install New Software.
push Add button and input this url.
http://download.aptana.com/studio3/plugin/install
and click OK to install plugin.


Creating Rails project
On Eclipse Menubar, File > New > Other


select Rails Project and click Next.

input Project Name “testproj” . Click Finish.

Start webric server
[bash]
$ cd ~/workspace/testproj
$ rails s
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
[/bash]
if “Could not find a JavaScript runtime” is shown ,install nodejs.
[bash]
$ sudo apt-get install nodejs
[/bash]
if you use mysql, install libmysqlclient-dev.
[bash]
$ sudo apt-get install libmysqlclient-dev
[/bash]
Test Running
[bash]
$ rails s
=> Booting WEBrick
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-01-16 16:59:59] INFO WEBrick 1.3.1
[2014-01-16 16:59:59] INFO ruby 2.0.0 (2013-11-22) [i686-linux]
[2014-01-16 16:59:59] INFO WEBrick::HTTPServer#start: pid=19531 port=3000
[/bash]
Access Rails app with your browser.
URL is http://localhost:3000
if the top page is shown,please shutdown rails server with Ctrl + C key.

Debugging with Eclipse
On Eclipse Menubar, Window > Show View > Servers.

Bottom of Eclipse, Server view is shown.
Select testproj ,and click Edit button.

Here is very very important Point!!
As a default, value of Host/IP is 0.0.0.0 , change 127.0.0.1 !!
and click OK.

click debug button for debugging rails.

if “Ruby program /home/xxx/workspace/testproj/script/rails does not exist.” is shown, create script folder.
[bash]
$ cd ~/workspace/testproj
$ cp bin/ script -R
[/bash]

install IDE debugger.
[bash]
$ gem install ruby-debug-ide
[/bash]
Create a sample application
[bash]
$ rails generate scaffold Sample name:string email:string
$ rake db:migrate
[/bash]
Test Running
click debug button on server view for debugging rails.
access http://localhost:3000/samples with your browser.


Now debugging with eclipse
Open app>>controllers>>samples_controller.rb from Eclipse Project Explorer.
and set break point.

[bash]
def index
@samples = Sample.all
end
[/bash]
reload the page with your browser.
if a screen like this is shown .you get a debugging environment of Rails app.Congratulations!

22 Comments
I am really impressеd with your writing skills as well as with the layout on your blog.
Is this a paid theme or did you ϲustomіze it yourself? Anyway keep
up the excellent quality writing, it is rare to see a grreat blog likе thiѕ
οne nowadays.
Ηi there! I just would lіҝe to gіve you a bbig thumbs up forr the ɡreat
info you have got here on this poѕt. I will be comіng bɑϲk to your աebsite for more soon.
Ӏ have been surfing oոline more than three hours tߋday, ʏet
I never found any interesting article like yours.
It’s pretty wortɦ еnough for me. In my view, if all web owners and Ƅloggers made good content
as you did, the net will be much more useful than ever before.
I truly love your site.. Excellent colors & theme. Did you make this site yourself?
Please reply back as I’m looking to create my own personal website and would like to learn where you got this from or exactly what the theme is called.
Thank you!|
Hi, i read your blog post from time to time so i possess a equivalent a single and that i was just asking yourself if you get lots of spam responses? If you do how will you stop that, any kind of plugin as well as anything you can suggest? I buy a great deal recently it’s operating us insane therefore any assistance is very much appreciated.
Awesome post.
I have read so many posts concerning the boogger lovers except tis
paragrqph is actually a nice article, keerp it up.
Your means of telling all in this paragraph is in fact nice,
all be able to simply know it, Thanks a lot.
Hello there, I discovered your website by the use of Google at the same time as
looking for a comparable matter, your site came up, it seems great.
I’ve bookmarked it in my google bookmarks.
Hi there, simply was aware of your weblog through Google, and found
that it is really informative. I’m gonna be careful
for brussels. I will appreciate when you proceed this in future.
Many other folks will probably be benefited from your writing.
Cheers!
Your style is very unique in comparison too other people I
have read stuff from.Thank you for posting when you have
the opportunity, Guess I’ll just bookmark this page.
Hello there! This iis my first comment here so I just wanted to give a quick shout out and tell you I really enjoy reading your blog posts.
Can you suggwst any other blogs/websites/forums
that go over the same topics? Thank you so much!
Heyy There. I discovered your blolg the usaage off msn.
This is an extremely neatly written article. I’ll make
sure to bookmark it and come back to read
extra of your helpfuul information. Thank you forr thhe post.
I will certainly return.
I used to be able to find good advice from your blog posts.
Hurrah, that’s what I was seeking for, what a material!
present here at this weblog, thanks admin of this web site.
Hi would you mind letting me know which hosting company you’re using?
I’ve loaded your blog in 3 completely different internet browsers and I must say this blog loads a lot quicker then most.
Can you recommend a good web hosting provider at a fair price?
Thanks, I appreciate it!
I like it when people get together and share ideas.
Great site, continue the good work!
I’m really impressed with your writing skills and also with the layout on your weblog.
Is this a paid theme or did you customize it yourself? Either
way keep up the nice quality writing, it’s rare to see a nice blog like this
one these days.
I do not even know how I ended up here, but I thought this post was great. I do not know who you are but definitely you are going to a famous blogger if you aren’t already 😉 Cheers!
I am very happy to read this. This is the kind of manual that needs to be given and not the random misinformation that is at the other blogs. Appreciate your sharing this best doc.
Thanks very interesting blog!
Hey There. I found your blog using msn. This is a very well written article.
I will be sure to bookmark it and return to read more of your useful information. Thanks for the post.
I’ll certainly return.
Pretty nice post. I just stumbled upon your weblog and wanted to mention that I have truly enjoyed browsing your weblog
posts. After all I’ll be subscribing for your rss feed and I am hoping you write
once more soon!