Miles to go ...

Arun Gupta is a Technology Evangelist for Web Services and Web 2.0 Apps at Sun. He was the spec lead for APIs in the Java platform, committer in multiple Open Source projects, participated in standard bodies and contributed to Java EE and SE releases.
« Web 2 Summit - Cool... | Main | Mid West Java Tech... »

http://blogs.sun.com/arungupta/date/20071016 Tuesday October 16, 2007

TOTD #14: How to generate JRuby-on-Rails Controller on Windows (#9893)

The current Rails Gem (version 1.2.5) gives an error when creating a Controller in a JRuby-on-Rails application on Windows. It gives the following error during controller creation as shown below:

C:/testbed/ruby/jruby-1.0.1/lib/ruby/1.8/pathname.rb:420:in `realpath_rec': No such file or directory -C:/testbed/ruby/jruby-1.0.1/samples/rails/hello/C: (Errno::ENOENT)
    from C:/testbed/ruby/jruby-1.0.1/lib/ruby/1.8/pathname.rb:453:in `realpath'
    from C:/testbed/ruby/jruby-1.0.1/lib/ruby/gems/1.8/gems/rails-1.2.4/lib/initializer.rb:543:in `set_root_path!'
    from C:/testbed/ruby/jruby-1.0.1/lib/ruby/gems/1.8/gems/rails-1.2.4/lib/initializer.rb:509:in `initialize'
    from ./script/../config/boot.rb:35:in `new'
    from ./script/../config/boot.rb:35:in `run'
    from ./script/../config/boot.rb:35
    from :1:in `require'
    from :1

and Rails 1.2.4 gives exactly the same error. This is Ticket #9893. This actually happens because of JRUBY-1401.

The workaround is to use Rails 1.2.3. If you have already installed the latest Rails plugin, then you can uninstall it using the command:

C:\testbed\ruby\jruby-1.0.1\bin>gem uninstall rails
Successfully uninstalled rails version 1.2.5
Remove executables and scripts for
'rails' in addition to the gem? [Yn] y
Removing rails

And then install Rails 1.2.3 as:

gem install rails --include-dependencies --version 1.2.3 --no-ri --no-rdoc
Successfully installed rails-1.2.3
Successfully installed activesupport-1.4.2
Successfully installed activerecord-1.15.3
Successfully installed actionpack-1.13.3
Successfully installed actionmailer-1.3.3
Successfully installed actionwebservice-1.2.3

Now create a new application as shown below:

jruby -S rails hello

And then create a controller as:

jruby script\generate controller say hello
exists app/controllers/
exists app/helpers/
create app/views/say
exists test/functional/
create app/controllers/say_controller.rb
create test/functional/say_controller_test.rb
create app/helpers/say_helper.rb
create app/views/say/hello.rhtml

Hope you find it useful and this bug is fixed in the next version of Rails.

Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.

Technorati: totd rubyonrails jruby windows

del.icio.us | furl | simpy | slashdot | technorati | digg
Comments:

[Trackback] JRuby 1.0.2 was released last week. A total of 99 issues were fixed but I'm particularly excited about JRUBY-1347, JRUBY-1350, JRUBY-1401 and JRUBY-1410. These are some issues that I faced (1347 here, 1350 here, 1401 here, 1410 here) on...

Posted by Arun Gupta's Blog on November 09, 2007 at 07:17 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
« Web 2 Summit - Cool... | Main | Mid West Java Tech... »

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.

--> ajax ajaxworld conf eclipse fitness gem glassfish glassfishday hyderabad india indigo interoperability javaone javaone2008 jax-ws jmaki jpa jruby mac marathon metro microsoft mysql netbeans phobos photography presos railsconf ruby rubyonrails running runninglog runsfm screencast siliconvalleymarathon sun suntechdays swdp tango theserverside totd training traveltips v3 vista wcf web2.0 webservices webtier windows wsaddressing wsit
Locations of visitors to this page

calendar

« July 2008
SunMonTueWedThuFriSat
  
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today

Stats

Today's Page Hits: 1010


Total # blog entries: 629
Total # comments: 1787

www.flickr.com
This is a Flickr badge showing public photos from ArunGupta. Make your own badge here.
Add to Technorati Favorites

Last 50