Friday September 07, 2007
TOTD #7: Switch between JRuby and CRuby interpreter in NetBeans 6
The NetBeans 6 IDE comes pre-configured with JRuby interpreter. This TOTD explains how the JRuby interpreter can be swapped with a C-based Ruby interpreter and vice versa.
Views", "say", and open "hello.rhtml".hello.rhtml" window and select "Run
File" (Shift+F6 is the default shortcut). This starts the WEBrick
container and displays "http://localhost:3000/say/hello".
It shows the following in the output window:=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2007-09-07 13:40:29] INFO WEBrick 1.3.1
[2007-09-07 13:40:29] INFO ruby 1.8.5 (2007-09-06) [java]
[2007-09-07 13:40:29] INFO WEBrick::HTTPServer#start: pid=6336176
port=3000
127.0.0.1 - - [07/Sep/2007:13:40:33 PDT] "GET /say/hello HTTP/1.1"
200 83
- -> /say/helloruby -S gem install rails -y --no-rdocTools" menu, select "Options",
"Ruby", and change the value of "Ruby Interpreter"
from

x"
in the bottom right corner of the IDE.
hello.rhtml" window and select "Run
File" (Shift+F6 is the default shortcut). This starts the WEBrick
container using the C-based Ruby interpreter and displays "http://localhost:3000/say/hello".
It shows the following in the output window:=> Booting WEBrick...
[2007-09-07 14:13:54] INFO WEBrick 1.3.1
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2007-09-07 14:13:54] INFO ruby 1.8.6 (2007-03-13) [i386-mswin32]
[2007-09-07 14:13:54] INFO WEBrick::HTTPServer#start: pid=3900 port=3000
127.0.0.1 - - [07/Sep/2007:14:13:56 Pacific Daylight Time] "GET
/say/hello HTTP/1.1" 200 83
- -> /say/hello
127.0.0.1 - - [07/Sep/2007:14:14:20 Pacific Daylight Time] "GET
/say/hello HTTP/1.1" 200 83
- -> /say/helloOf course, you can switch back to the JRuby interpreter using the same mechanism.
Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.
Technorati: totd rubyonrails jruby ruby netbeans
Posted by Arun Gupta in web2.0 | Comments[10]
|
|
|
|
| JRuby on Rails, NetBeans 6 and GlassFish V2 - Simplified Steps
The NetBeans IDE has simplified the steps to deploy JRuby on Rails application on GlassFish. This blog explains the steps and is an update to screencast #web6.
Download"
button in the Ruby column.New Project...".
Take all the defaults as shown below:
Next" and enter the values as shown below:
Add rake targets to support app server
deployment (.war)". This downloads the
goldfish (nee rails integration) plugin and installs in your
application. Choose the database that you'd like to work with using the
combo box:
Finish" button. I'm choosing the default
database (MySQL) in this case.mysqld -nt
--user root' in MYSQL_HOME/bin directory on Windows or
'./bin/mysqld_safe' from MYSQL_HOME directory
on Unix flavors.mysqladmin -u root create RailsApplication9_developmentGenerate..."
and enter the values as shown below:
OK".Generate..."
and enter the values as shown:
OK".Database Configurations",
"migrate" and open "001_create_greetings.rb".
Change the "self.up" helper method such that it looks
like:def self.up
create_table :greetings do |t|
t.column :data, :string
end
endRun Rake Target',
'db', 'migrate'. This generates the
appropriate database tables and the following is shown in the output
window:(in C:/Users/Arun Gupta/Documents/NetBeansProjects/RailsApplication9)
== CreateGreetings: migrating
=================================================
-- create_table(:greetings)
-> 0.1010s
== CreateGreetings: migrated (0.1110s)
========================================C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql --user root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.45-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use RailsApplication9_development;
Database changed
mysql> insert into greetings values (1, "Hello from database!");
Query OK, 1 row affected (0.10 sec)
mysql> exit;
ByeConfiguration" and
open "database.yml". Change the database entry in
production environment to point to "RailsApplication9_development"
instead of "RailsApplication9_production".Controllers", open "say_controller.rb"
and change "hello" helper method such that it looks
like:def hello
@hello_string = Greeting.find(1).data;
endViews", "say", open "hello.rhtml"
and add the following fragment at the bottom of the page:<%= @hello_string %>Run
Rake Target', 'war', 'standalone', 'create'
as shown here:
(in C:/Users/Arun Gupta/Documents/NetBeansProjects/RailsApplication9)
Assembling web application
Adding Java library commons-pool-1.3
Adding Java library activation-1.1
Adding Java library jruby-complete-1.0
Adding Java library bcprov-jdk14-124
Adding Java library rails-integration-1.1.1
Adding web application
Adding Ruby gem rails version 1.2.3
Adding Ruby gem rake version 0.7.3
Adding Ruby gem activesupport version 1.4.2
Adding Ruby gem activerecord version 1.15.3
Adding Ruby gem actionpack version 1.13.3
Adding Ruby gem actionmailer version 1.3.3
Adding Ruby gem actionwebservice version 1.2.3
Adding Ruby gem ActiveRecord-JDBC version 0.5
Creating web archiveRailsApplication9.war" in the project
directory.lib\ant\bin\ant -f setup.xmlbin\asadmin start-domainRailsApplication9.war) in "domains/domain/autodeploy"
directory.The application is accessible at "http://localhost:8080/RailsApplication9/say/hello".
Here are the improvements from the last time:
database.yml"
using default values for that database.war:standalone:create"
rake target. This allows the database to be accessed using the Ruby adapter
instead of the JDBC adapter and also uses the original format of "database.yml".Technorati: jruby ruby rubyonrails glassfish netbeans jrubyonglassfish mysql
Posted by Arun Gupta in web2.0 | Comments[23]
|
|
|
|
|
Today's Page Hits: 2326
Total # blog entries: 994