Ruby on Rails is an open source Web application framework that allows you to easily build Web applications using a model view controller architecture. Ruby on Rails is gaining a substantial following in the developer community, and it has been adopted in many commercial and private sites. Its strength is in its ability to quickly and iteratively build Web applications in an agile manner.
IBM Lotus Connections is social software for businesses that includes Profiles to find people, Blogs to present your ideas, Dogear to save and share bookmarks, Communities to work with people who share a common interest, and Activities to organize your work.
In this article, we use Ruby on Rails to build a Web application that communicates with a Lotus Connections Dogear server to retrieve and display bookmark information using REST services.
In this sample application, we show various techniques that are used to provide the following functionality:
- View all public bookmarks
- View personal bookmarks
- Page through bookmarks
- View bookmark tag cloud
- Filter bookmarks based on tags
Figure 1. The running sample bookmarks page

In this article we use a system running Microsoft® Windows® as our development system, but any operating system that supports Ruby on Rails can be used. For this article, we used the following software environment:
- Java⢠1.5 or higher
- JRuby 1.1.3 with the following gems installed:
- Ruby on Rails 2.1.0
- Jruby-openssl (0.2.3) (needed only when accessing the Lotus Connections server through HTTPS)
- Warbler (0.9.10), which includes JRuby Rack (needed only if you want to build a deployment WAR file)
To verify your environment, you can list the installed gems using the jruby -S gem list at the Windows command prompt.
NOTE: The -S parameter tells JRuby to look for the script in the JRuby home /bin directory rather than in the current directory.
Figure 2. The gem list console output

This section describes the steps that you follow to recreate the sample application. Part of the process includes using the standard Ruby on Rails generation techniques, and for other parts you add the accompanying sample source files, which you can find in the Download section of this article.
The first task you do when creating a new Ruby on Rails application is to generate the base directory structure and default files. You can do so at the command prompt by running the rails script in the parent directory in which you want to create your application. You pass the rails script the name of the application, which becomes the application directory name as well.
Run the following command to generate the connections application:
C:\JRuby\samples>jruby -S rails connections
Figure 3. The rails command console output

With the basic application framework in place, letâs start the built-in WEBrick server and run the skeleton framework. This approach ensures that your environment is set up correctly.
First, change to the connections directory, and then run the server script to start the server. For example:
C:\JRuby\samples\connections>jruby script/server
Figure 4. The rails server start console output

With the server started, open your favorite browser and point it at the http://localhost:3000 URL. This step shows the default index page.
If you click the âAbout your applicationâs environmentâ link, you get errors because a database has not been configured.
Figure 5. The Ruby on Rails welcome page

Because this Ruby on Rails application does not use a back-end database, you need to do some work to keep Ruby on Rails running smoothly.
First, stop the server if it is running. You can stop the server by pressing Ctrl + C in the server console.
Open your favorite editor, and add the following line to: \config\environment.rb in the connections project. This line tells Ruby on Rails that you are not using these frameworks.
config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
Delete the \config\database.yml file. Because you are not using a database, you do not need its configuration file.
Comment out the code shown in listing 1 in \config\initializers\new_rails_defaults.rb.
Listing 1. Code to comment out
# Only save the attributes that have changed since the record was loaded. #ActiveRecord::Base.partial_updates = true # Include ActiveRecord class name as root for JSON serialized output. #ActiveRecord::Base.include_root_in_json = true |
Delete the connections\public\index.html file. You will redefine the default page using the routes.rb, so this file must not exist.
In a typical Ruby on Rails application, you use the scaffold to generate the base model view controller and database migration files. Because this application does not use a database, the scaffolding generation does not provide much benefit; instead, this article provides all the sample files that you need to run the application.
Here you install the files that accompany this article. To do this step, use your favorite compression tool and extract the connections_sample.zip content into the connections directory. Allow the extraction process to overwrite the files application_helper.rb and routes.rb, if asked.
For the application to communicate with the Lotus Connections Dogear server, you need to specify its location. This information is located in a YAML file so that you can configure it easily without modifying any source code. To set the server URL, use an editor and open the config\server_info.yaml file in your project. Set the URL to point to the Dogear server that you intend to use. The default URL points to the Lotus Greenhouse server, but you must sign up for an account to access it.
NOTE: This file is read only when the server is started, so if you make any changes you need to restart the server.
For example, enter the code shown in listing 2.
Listing 2. Configuring the sample
dogear_info:
dogear_url: https://greenhouse.lotus.com/dogear
dogear_test_user:
default_result_size: 15
|
To run the sample, you need to start the server as you did in the initial testing.
For example, enter the following:
C:\JRuby\samples\connections>jruby script/server
After the server is started, open your browser and point it at the http://localhost:3000 URL.
If you are using a secure connection to talk to the Lotus Connections server, as the Lotus Greenhouse server does, you are prompted to enter your credentials as shown in figure 6.
Figure 6. The sample application login page

After you enter your credentials or if you are not using a secure connection, you can see the page containing the public bookmarks as shown in figure 7.
Figure 7. The sample application bookmarks page

The architecture in this application is consistent with most other Ruby on Rails applications in which the Ruby on Rails model view controller architecture is used. The major difference in this application is that the model interacts with the Lotus Connections Dogear server through REST services, whereas a Ruby on Rails application commonly accesses a relational database.
Figure 8 shows the flow from an initial browser request through the Ruby on Rails server to the back-end server and then back to the Browser.
Figure 8. The application architecture

The following sections describe the model, view, and controller components that make up this application.
The model in the model view controller (MVC) architecture is responsible for managing the application data and any business logic. The data in this application is accessed through a REST service call to a Lotus Connections Dogear server. The server returns its results in XML. The two models described below are used to interface the data from the server to the controller and view. Both the bookmark and tag models extend the ConnectionsUtilities::FeedBase class, which provides all the common functionality for fetching the data. The subclasses are responsible only for knowing the request URL and for formatting the different result data.
The bookmark model is used to access the Atom feed that makes up a list of bookmarks. This model is used to get either a userâs bookmarks list or a list of all public bookmarks. The bookmark model can be used to perform a query for a specific tag or set of tags to allow filtering of the bookmark results.
Listing 3 is an example of a bookmark Atom feed containing a single bookmark entry. Typically you have several <entry> elements that contain each bookmark.
Listing 3. A bookmark Atom feed
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:snx="http://www.ibm.com/xmlns/prod/sn"
xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
<generator uri="http://www.ibm.com/xmlns/prod/sn" version="2.0">
Lotus Connections - Dogear</generator>
<title>Dogear - Bookmarks for Thomas Beauvais</title>
<link rel="self" type="application/atom+xml" href=
"https://greenhouse.lotus.com/dogear/atom/mybookmarks?
sort=date&sortOrder=desc&lang=en" />
<link rel="http://www.ibm.com/xmlns/prod/sn/tag-cloud"
type="application/atomcat+xml"
href="https://greenhouse.lotus.com/dogear/tags/mybookmarks?
sort=date&sortOrder=desc&lang=en" />
<link rel="alternate" type="text/html"
href="https://greenhouse.lotus.com/dogear/html/mybookmarks?sort=
date&sortOrder=desc&lang=en"/>
<opensearch:totalResults>1</opensearch:totalResults>
<id>tag:dogear.ibm.com,2005:feed://mybookmarks?sort=date&
sortOrder=desc&lang=en</id>
<updated>2008-08-28T11:56:09-04:00</updated>
<author><name>Thomas Beauvais</name>
<email>tbeauvai@us.ibm.com</email></author>
<entry>
<id>tag:dogear.ibm.com,2005:link:9818d0c9-e67c-4ad2-b3fe-62e61c2b2040
</id>
<title>Lotus Connections Tools</title>
<category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="bookmark" />
<link href="https://greenhouse.lotus.com/dogear/nav/toolbox?appName=
dogear" />
<published>2008-08-28T11:56:09-04:00</published>
<updated>2008-08-28T11:56:09-04:00</updated>
<category term="connections"/>
<category term="tools"/>
<author><email>tbeauvai@us.ibm.com</email><name>
Thomas Beauvais</name><uri>https://greenhouse.lotus.com/dogear/html?
email=tbeauvai%40us.ibm.com&lang=en</uri></author>
<snx:clickcount>0</snx:clickcount>
<snx:linkcount>2</snx:linkcount>
<link rel="http://www.ibm.com/xmlns/prod/sn/same" type="application/atom+xml"
href="https://greenhouse.lotus.com/dogear/atom?for=
https%3a%2f%2fgreenhouse.lotus.com%2fdogear%2fnav%2ftoolbox
%3fappName%3ddogear&lang=en" />
</entry>
.......
</feed>
|
The most interesting method in the Bookmark class is find(..). This method is used to retrieve bookmarks based on arguments and user credentials. The find(..) method is used in BookmarksController to fetch the bookmarks for use in the view.
@bookmarks = Bookmark.find(args, user_name, user_password)
The result of this call is an instance of an Atom feed, which can be used to enumerate the Atom entries.
For example, you can do the following to display each entryâs title and link value given the find(..) call:
@bookmarks.entries do |entry|
puts "Title: " + entry.title
puts "Link: " + entry.link
end
The tag model is used to access the tag information related to a set of bookmarks. This information is in a proprietary XML format. The tag information can be specific for the userâs bookmarks or for the global list of bookmarks.
Listing 4 is an example of the tag information format for a userâs bookmarks.
Listing 4. Tag information format
<app:categories xmlns:app="http://www.w3.org/2007/app"
xmlns="http://www.w3.org/2005/Atom"
xmlns:snx="http://www.ibm.com/xmlns/prod/sn" fixed="no">
<category term="api" snx:frequency="1" />
<category term="connections" snx:frequency="4" />
<category term="css" snx:frequency="1" />
<category term="gadgets" snx:frequency="1" />
<category term="javacc" snx:frequency="2" />
<category term="jruby" snx:frequency="1" />
<category term="rails" snx:frequency="1" />
<category term="ruby" snx:frequency="1" />
</app:categories>
|
As with the bookmarks model, the most interesting method in the tag class is find(..). This method is used to retrieve the tags based on the arguments and the user credentials. The find(..) method is used in BookmarksController to fetch the tags for use in the viewâs tag cloud.
@tags = Tag.find(args, user_name, user_password)
The result of this call is an instance of an REXML document, which can be used directly to enumerate the tags.
For example, you can enter the following code to display each tag value given the find(..) call:
@tags.elements.each("//category") do |tag|
puts tag.attributes['term']
end
The view in the MVC architecture is responsible for rendering the user interface, which typically means displaying the model data in a user-friendly format.
The following sections describe the details for each of the views. A view can be an entire page, or it can be broken into components by leveraging the partial page functionality in Ruby on Rails.
The application layout file provides the common page layout into which specific views are inserted. In this application, it provides the page header and brings in the common stylesheet files. You can find the application layout file in your project here:
connections\app\views\layouts\application.html.erb
The following is the contents of that file.
Listing 5 shows the contents of the connections\app\views\layouts\application.html.erb file. Note that the <%= yield %> is where the subviews are inserted. All the views in this application use this application layout to display their contents.
Listing 5. The connections\app\views\layouts\application.html.erb file
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Bookmarks: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
<%= stylesheet_link_tag 'connections' %>
</head>
<body>
<div class="banner">
<%= image_tag("/images/rails.png") %>
<%= @page_title || "<i>Bookmarks</i>" %>
</div>
<div class="background">
<%= yield %>
</div>
</body>
</html>
|
The bookmark views for the userâs bookmarks (My Bookmarks) and the global bookmarks (All Bookmarks) are identical. Because of this similarity, the two bookmarks views leverage the same bookmarks.rhtml partial file, which is described in the "Partial views" section of this article.
The following is the contents of the connections\app\views\bookmarks\index.html.erb file and the connections\app\views\bookmarks\my_bookmarks.html.erb file:
<%= render(:partial => "connections/bookmarks") %>
This section describes the use of Ruby on Rails partial views, which are logical pieces of the view made into components that you can reuse. Partial views also help make the view pages easier to understand and to maintain.
Bookmarks
The _bookmarks.rhtml partial file is responsible for looping through and displaying the bookmark model data. A link is generated to the target site for each bookmark entry. The bookmark title is used as the link text.
Two mode links are provided to toggle between the All Bookmarks and My Bookmarks selections. These links switch from the index or my_bookmarks action in the bookmarks controller.
Notice that the paging links and tags for the bookmarks are delegated to two other partial files. This delegation makes the code easier to read and to maintain, and it allows you to reuse that functionality. For example, you might want to place the paging links on the top of the page and on the bottom. To do that, you add a call to the render partial for the paging at the top of the bookmarks.
This page also includes a link that displays the current user and that allows you to switch to the login page to change the current user.
Listing 6 shows the contents of the connections\app\views\connections\_bookmarks.rhtml file.
Listing 6. The connections\app\views\connections\_bookmarks.rhtml file
<div class="nav_links">
<div class="nav_link"><%= link_to_unless "my_bookmarks" == params[:action],
"My Bookmarks",{:controller => "bookmarks", :action =>
"my_bookmarks"} %></div>
<div class="nav_link"><%= link_to_unless "my_bookmarks" != params[:action],
"All Bookmarks",{:controller => "bookmarks", :action => "index"} %>
</div>
<div class="user_link"><%= link_to session["user_email"] +
" (change user)",{:controller => "login", :action => "login"}
unless session["user_email"].nil? %></div>
</div>
<div class="left_pane">
<%= render(:partial => "connections/tags) %>
</div>
<div class="right_pane">
<div class="bookmarks">
<% @bookmarks.entries do |entry|%>
<div>
<%= link_to entry.title, entry.link,:popup => true %>
</div>
<% end %>
</div>
<br/>
<%= render(:partial => "connections/paging") %>
<div class="powered">
Powered by dogear <%= image_tag("/images/dogear.gif") %>
</div>
</div>
|
Paging
The _paging.rhtml partial file is responsible for the display of the paging links that allow users to enumerate through a large number of bookmarks when the data cannot fit on a single page and for scalability when you donât want to retrieve all the bookmarks at once from the server. The get_paging_info method in the BookmarksHelper module is used to get the paging information. This method uses the total results supplied by the Atom bookmark feed and the items per page specified in the config\server_info.yaml file to calculate the link information. The paging_link method, also located in the BookmarksHelper module, is a simple wrapper around the Ruby on Rails link_to_unless method; it takes a code block with the rule to determine if the link should be enabled. For example, if you are on the first page, the link that takes you to the previous page needs to be disabled.
Listing 7 shows the contents of the connections\app\views\connections\_paging.rhtml file.
Listing 7. The connections\app\views\connections\_paging.rhtml file
<div class="paging_links">
<% current_page, num_pages = get_paging_info %>
<%= paging_link("[First]", 1) {current_page == 1} %>
<%= paging_link("[Previous]", current_page - 1) {current_page == 1} %>
<%= "Page #{current_page} of #{num_pages}" %>
<%= paging_link("[Next]", current_page + 1) {current_page >= num_pages} %>
<%= paging_link("[Last]", num_pages) {current_page >= num_pages} %>
</div>
|
Tags
The _tags.rhtml partial file is responsible for displaying the tag cloud that is associated with the current bookmarks. This view loops over the tag elements from the tag model and builds a list of links back to the bookmarks controller where the tag name is added as parameter. The controller uses the tag parameter to filter the next request for bookmarks.
Also included in this view is a form in which users can manually enter one or more tag names that can also be submitted back to the controller to provide the same bookmark filtering.
Listing 8 shows the contents of the connections\app\views\connections\_tags.rhtml file.
Listing 8. The connections\app\views\connections\_tags.rhtml file
<div class="tags_wrapper">
<div class="tags_title">Tags</div>
<p>
<%= link_to "(view all)" %>
</p>
<% form_tag do %>
<%= text_field_tag(:tag_name, params[:tag_name]) %>
<input type="submit" value="Find">
<% end %>
<% @tags.elements.each("//category") do |tag| %>
<div class="tags">
<% term = tag.attributes['term'] %>
<%= link_to term,{:tag_name => term} %>
</div>
<% end %>
</div>
|
Login
The login page is used to collect users' credentials and submit them to the set_credentials action in the login controller. This page is rendered whenever credentials are needed to access the backend server or to display the current userâs personal bookmarks. In cases where HTTPS is used to communicate with the Lotus Connections server, both the user name and password input fields are displayed. When not using HTTPS, only the user name input field displays because it is needed to display the userâs bookmarks.
Listing 9 shows the contents of the connections\app\views\login\login.html.erb file.
Listing 9. The connections\app\views\login\login.html.erb file
<div class="login">
<div class="login_padding">
<h1>Login</h1>
<% form_tag(:action => "set_credentials") do %>
<div class="row">
<span class="label">Email:</span>
<span class="formw">
<%= text_field_tag(:email, session["user_email"]) %></span>
</div>
<% if ConnectionsUtilities::UrlHelper.is_https?
(DOGEAR_INFO['dogear_url'])%>
<div class="row">
<span class="label">Password:</span>
<span class="formw"><%= password_field_tag(:password,
session["user_password"]) %></span>
</div>
<% end%>
<div class="buttons">
<%= submit_tag "Submit", :name=>"submit" %>
<%= submit_tag "Cancel", :name=>"cancel" %>
</div>
<% end %>
</div>
</div>
|
The controllers are responsible for coordinating the interaction between the model and the view and for handling incoming user requests.
For example, if a GET request comes from the userâs browser for a list of bookmarks, the following high-level processing happens. The controller tells the bookmark model to find the bookmark list, and it makes the results available to the view. Next, the controller dispatches to the index.html.erb page, which renders the bookmark list.
The following sections describe the details for each of the controllers.
The bookmarks controller provides the logic for interacting with the bookmark and tag models. Because the bookmark and tag data is rendered from the same view, there is no need for separate controllers.
The two primary actions provided by the bookmarks controller are the index and my_bookmarks. The index action is used to fetch and then display a list of public bookmarks; the my_bookmarks action is used to fetch and display a list of the current userâs personal bookmarks. Because these are similar actions, they share a common method called get_bookmarks, which does most of the work.
Listing 10 shows the index and my_bookmarks methods from the BookmarksController class.
Listing 10. The index and my_bookmarks methods
# GET /bookmarks
def index
if get_bookmarks
respond_to do |format|
format.html # index.html.erb
end
end
end
# GET /bookmarks/my_bookmarks
def my_bookmarks
args = {"email" => session["user_email"]}
if get_bookmarks(args)
respond_to do |format|
format.html # index.html.erb
end
end
end
|
The get_bookmarks method builds the required arguments to pass to the Tag.find(..) and Bookmark.find(..) methods. These arguments control such things as the bookmark filtering based on tags and the paging information.
If incorrect credentials are specified, this method redirects to the logon controller instead of displaying a stack trace error message.
Listing 11 shows the get_bookmarks method from the BookmarksController class.
Listing 11. The get_bookmarks method
def get_bookmarks(args = {})
# common argument for both Tag and Bookmark.
args.store("lang", "en")
begin
# find the tags for the current user
@tags = Tag.find(args, session["user_email"], session["user_password"])
# add a bookmark "tag" if one was selected
args.store("tag", params[:tag_name]) unless params[:tag_name].nil?
# used by the paging to specify which page of the data we are looking for
args.store("page", params[:page]) unless params[:page].nil?
# used by the paging to specify how many items per page
args.store("ps", DOGEAR_INFO['default_result_size'].to_s)
# find the bookmarks for the current user. With or without a specified tag name
@bookmarks = Bookmark.find(args, session["user_email"], session["user_password"])
# redirect to the login controller if Unauthorized error
rescue OpenURI::HTTPError => detail
if(detail.io.status[0] == "401")
redirect_to(:controller => "login", :action => "login")
return false
else
raise detail
end
end
return true
end
|
A Ruby on Rails before_filter method is used to wrap calls to the controllerâs actions with a credential check. This filter redirects to the login controller if the user credentials have not been set but are required.
The following line in the BookmarksController class adds the check_credentials method before filter:
before_filter :check_credentials
Listing 12 shows the check_credentials method from the BookmarksController class.
Listing 12. The check_credentials method
def check_credentials
# we need a user_email if we are searching for a user's bookmarks, or
we need credentials if using HTTPS
if ("my_bookmarks" == params[:action] and session["user_email"].nil?) or
(ConnectionsUtilities::UrlHelper.is_https?(DOGEAR_INFO['dogear_url']) and
(session["user_email"].nil? or session["user_password"].nil?))
session["return_to"] = request.request_uri
redirect_to(:controller => "login", :action => "login")
end
end
|
The login controller provides the logic for displaying the login page and handling the login submit action. The login submit action is handled by the set_credentials action in the controller, where it fetches the credentials from the request parameters and stores them in the userâs session for later use.
Listing 13 shows the set_credentials method from the LoginController class.
Listing 13. The set_credentials method
def set_credentials
if params['submit'].nil?
redirect_to(:controller => "bookmarks", :action => "index")
return
end
if params[:email].nil? or params[:email].empty?
session["user_email"] = nil
session["user_password"] = nil
else
session["user_email"] = params[:email]
session["user_password"] = params[:password]
end
# go back to the caller
session["return_to"] ? redirect_to(session["return_to"]) :
redirect_to(:controller => "bookmarks")
end
|
This article mentions a couple of modules that contain some important application logic:
- ConnectionsUtilities. The ConnectionsUtilities module contains several helper classes that are used by the application. Take a look at this module to see how it is used. The module is located in connections\lib\connections_utilities.rb.
- BookmarksHelper. The BookmarksHelper module contains the code to support the paging links used to page through the bookmark items. Take a look at this module to see how it is used. The module is located in connections\app\helpers\bookmarks_helper.rb.
The only change to the Ruby on Rails routes file allows an incoming request without a controller to be mapped to the bookmarks controller. The mapping causes this URL http://localhost:3000 to run the index action on the BookmarksController class.
The following code snippet is from the connections\config\routes.rb file, and it does the mapping. This change is made for you when the sample is extracted.
# You can have the root of your site routed with map.root --
just remember to delete public/index.html.
map.root :controller => "bookmarks"
The config\initializers\app_init.rb class is used to initialize the configuration setting for the application. This setting is where the Lotus Connections server information is read and where the Open SSL is configured. Ruby on Rails executes all of the Ruby classes in the config\initializers directory during initialization. See listing 14.
Listing 14. The initializer class
# load the dogear server information(url) from a yaml file
DOGEAR_INFO = YAML.load_file("#{RAILS_ROOT}/config/server_info.yaml")["dogear_info"]
# Disable the verification of the target server certificate.
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
NOTE: If you want to enforce the verification, then you need to install the certificate on your server and point Ruby on Rails at it.
Building and deploying a WAR file
This section describes the optional ability to create a WAR file for this sample application for deployment to a Java application server.
Generating the WAR file is simple using the Warbler Ruby gem. If you donât have the Warbler 0.9.10 (or later) gem installed, then you should do so now. You can do this task by running the gem install warbler command from the command line. For example:
C:\JRuby\samples\connections>gem install warbler
To generate the WAR file, run the warble war command. For example:
C:\JRuby\samples\connections>jruby -S warble war
The result of running this command is a connections.war file in the C:\JRuby\samples\connections directory.
To deploy the WAR file, you can drop the connections.war file into the Tomcat webapps directory, for example:
Apache Software Foundation\Tomcat 5.5\webapps
Restart the Tomcat server.
After the application is deployed and started, you can run it by accessing a URL similar to this one:
http://localhost:8080/connections
Your host and port can vary.
IBM WebSphere Application Server
To run Ruby on Rails on the WebSphere® Application Server, you canât use the RackFilter. Instead, change the configuration to use the RackServlet.
To change to the RackServlet, update the web.xml.erb file in the jruby-1.1.3\lib\ruby\gems\1.8\gems\warbler-0.9.10 directory. In the web.xml.erb file, remove the filter and its mapping for the RackFilter, and replace it with the servlet and servlet mapping lines.
Remove the code shown in listing 15.
Listing 15. Code for filter and its mapping for RackFilter
<filter>
<filter-name>RackFilter</filter-name>
<filter-class>org.jruby.rack.RackFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>RackFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
|
Add the code shown in listing 16.
Listing 16. Servlet and servlet mapping code
<servlet>
<servlet-name>Rails</servlet-name>
<servlet-class>org.jruby.rack.RackServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Rails</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
|
Next, run the warble with the clean option:
C:\JRuby\samples\connections>jruby -S warble war:clean
Then rebuild the connections.war file:
C:\JRuby\samples\connections>jruby -S warble war
You can now use the WebSphere Application Server administration console to deploy the WAR file to the server.
As you work through the installation steps, set the context to /connections when you install the WAR file using the WebSphere Application Server Administration tool.
After the application is deployed and started, you can run it by accessing a URL similar to this one:
http://localhost:10040/connections
Your host and port can vary.
This sample provides a couple of unit tests for validating the bookmark and tag model code and connectivity. To run these tests, you must set the dogear_test_user and dogear_test_user_password in the server_info.yaml file. This information is used to connect to the Dogear server during the testing. See listing 17.
Listing 17. Connecting to the Dogear server
# Be sure to restart your server when you modify this file.
dogear_info:
dogear_url: https://greenhouse.lotus.com/dogear
dogear_test_user: user@myco.com
dogear_test_user_password: mypassword
default_result_size: 15
|
To run the tests, use the rake test:units command from the Lotus Connections application directory. For example:
C:\JRuby\apps\connections>jruby -S rake test:units
When the command is successful, you receive the following results:
2 tests, 26 assertions, 0 failures, 0 errors
In this sample application, you learned how to build a Ruby on Rails application that communicates with a Lotus Connections Dogear server through REST services.
This sample is a good starting point for integrating with the other Lotus Connections features such as Blogs, Profiles, Activities, and Communities. The techniques used here can also be applied to any back-end server that is exposed through REST services.
| Name | Size | Download method |
|---|---|---|
| connections_sample.zip | 17KB | HTTP |
Information about download methods
- Participate in the discussion forum.
-
Review the IBM WebSphere Portlet Factory Lotus Connections Integration Samples.
-
Check out the Lotus Greenhouse.
-
Learn more about IBM Lotus Connections Application Programming Interfaces.
-
Learn more about Ruby on Rails.
-
Refer to the JRuby home page.
-
Learn more about Warbler.
-
Learn more about JRuby Rack.
-
Read more about Deploying JRuby application on Tomcat, Glassfish, and WebSphere Portal V6.1.
Tom Beauvais is a Software Architect for IBM WebSphere Portlet Factory. Tom joined IBM in 2006 as part of the IBM acquisition of Bowstreet, and he brings more than 22 years of software development experience to his role at IBM. Prior to Bowstreet, he was a Development Manager in the Directory Management Group for Computer Associates.





