How to debug Rails app with eclipse on Ubuntu.(steps into,steps over,steps out)

How to debug Rails app with eclipse on Ubuntu.(steps into,steps over,steps out)

How to debug Rails app with eclipse on Ubuntu.(steps into,steps over,steps out)

How to debug Rails app with eclipse on Ubuntu.(steps into,steps over,steps out) への22件のコメント

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.

Screenshot from 2014-01-19 05:29:00

Screenshot from 2014-01-19 05:29:15

Creating Rails project

On Eclipse Menubar, File > New > Other

メニュー_002

メニュー_001

select Rails Project and click Next.
Screenshot from 2014-01-19 05:38:53

input Project Name “testproj” . Click Finish.

Screenshot from 2014-01-19 05:39:37

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.

rails-1

Debugging with Eclipse

On Eclipse Menubar, Window > Show View > Servers.

メニュー_003

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

Web - Eclipse _004

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.

Edit your Rails Server settings. _005

click debug button for debugging rails.

Web - Eclipse _006

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]

Problem Occurred _007

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.

Web - Eclipse _006

Testproj - Chromium_010

Now debugging with eclipse

Open app>>controllers>>samples_controller.rb from Eclipse Project Explorer.
and set break point.

Web - testproj-app-controllers-samples_controller.rb - Eclipse _008

[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!

Debug - testproj-app-controllers-samples_controller.rb - Eclipse _009

About the author:

Related Posts

22 Comments

  1. doudoune canada goose femme  - 2014年3月8日 - 10:46 AM
    /

    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.

  2. Louis  - 2014年3月20日 - 7:27 AM
    /

    Η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.

  3. air max 87  - 2014年3月21日 - 4:19 AM
    /

    Ӏ 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.

  4. Mirta  - 2014年4月10日 - 1:23 AM
    /

    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!|

  5. quest protein bars  - 2014年7月24日 - 10:51 PM
    /

    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.

  6. learn about china On wikipedia  - 2014年8月5日 - 1:43 PM
    /

    I have read so many posts concerning the boogger lovers except tis
    paragrqph is actually a nice article, keerp it up.

  7. B3-vitamiini  - 2014年8月7日 - 10:42 AM
    /

    Your means of telling all in this paragraph is in fact nice,
    all be able to simply know it, Thanks a lot.

  8. e cigarette starter kit  - 2014年8月7日 - 9:26 PM
    /

    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!

  9. best paid surveys  - 2014年8月14日 - 9:41 AM
    /

    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.

  10. taking surveys for money  - 2014年8月14日 - 1:22 PM
    /

    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!

  11. cash paid surveys  - 2014年8月15日 - 9:32 PM
    /

    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.

  12. Buy Cialis  - 2014年8月17日 - 7:07 PM
    /

    I used to be able to find good advice from your blog posts.

  13. Stick War  - 2014年8月29日 - 12:56 AM
    /

    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!

  14. nike shoes sale  - 2014年8月30日 - 2:43 AM
    /

    I like it when people get together and share ideas.
    Great site, continue the good work!

  15. nike free 5.0  - 2014年8月30日 - 9:40 AM
    /

    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.

  16. Shante Pendelton  - 2014年8月30日 - 11:16 AM
    /

    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!

  17. Lorene Robeson  - 2014年8月30日 - 12:05 PM
    /

    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.

  18. ایرانسل  - 2014年8月31日 - 7:15 AM
    /

    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.

  19. furniture stores near me  - 2014年8月31日 - 7:21 AM
    /

    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!

Back to Top