Warehouse Management System in Ruby On Rails
Warehouse Management System in Ruby On Rails
I. INTRODUCTION
These days Internet is the faster developing medium in the whole World. It is not only available via landline, but also mobile phone networks and still growing Wi-Fi hotspots. Along with the global network accessibility, the amount of mobile devices grows. More and more popular are telephones with screens exceeding 3 as well as netbooks small laptops with screen size of 10. This development in mobile technologies makes present business solutions obsolete and outdated. Most of current Enterprise Resource Planning (ERP) software is published and licensed per seat meaning they are tied to specific computers, usually stationed in offices. Another disadvantage is the need of installation the software itself as well as additional, required packages and libraries (like frameworks or relational databases). From the end user point of view, using ERP software via Internet browser should make their work considerably easier and shorten the time required to complete tasks. Applications like Internet Explorer, Firefox or Safari are preinstalled on almost every device that can access Internet. The need of software installation is removed completely, which guarantees that user can access application from virtually everywhere: in business trip via mobile or netbook, in the office and, if needed, from home. This kind of software is not tied to specific hardware or software platforms. For example, apart from creating orders by phone or in the e-commerce store, company agent can check product availability and place new order directly at clients office. -------------------------------------------------------------------------K. Durski, J. Murlewski, D. Makowski, B. Sakowicz, Department of Microelectronics and Computer Science, Technical University of Lodz, Poland Email: [email protected]
367
As an example we can use simple table called products with two columns name (string) and price (decimal). In such a case Active Record class name should be Product. In order to create new record in database, which executing query below would typically do [23]:
INSERT INTO products (name, price) VALUES ('Item 1', 99.99);
III. ARCHITECTURE
Described application was created using ModelView-Controller pattern used to separate data from logic and templates. Representational State Transfer (REST) [6] was used as well. This particular architecture was designed for stateless protocols (like HTTP) and defines sets of methods that should be used when creating web services. Method GET POST PUT DELETE Is safe? YES NO NO NO Is idempotent? YES NO YES YES
Fig. 2 Users and accounts table schema
HTTP specification, as described in RFC 2616 [7], describes 8 methods, each one being at the same time English verb. Four of those methods are used for diagnostic and informational purposes and are not used by our application. The other four methods are used to create, read, update and delete resources and their short comparison can be seen in Table 1.
In order to store data within application the MySQL 5.1 database is used [9, 10, 19]. It is free software with open source code, fully compatible with ANSI SQL standards. It supports relations and transactions (if InnoDB engine is used) and supports virtually all modern operating systems. To configure MySQL a special file needs to be created under config directory of our application called database.yml. That file will keep authentication details. Example is shown on Figure 3.
development: host: localhost adapter: mysql encoding: utf8 database: example_db username: root password: **** Fig. 3 Example database.yml file
368 On Figure 2 a schema of two main tables is shown users and accounts. Fields users.account_id is connected to accounts.id with foreign key and severs as a base for SaaS model. MySQL database support. Haml enables support for markup language with the same name. Authlogic small and easy extension that allows to quickly implement web session and users authentication. Also supports Facebook, Twitter and OpenID integration. Searchlogic extensively use metaprogramming feature in Ruby by creating set of methods for Rails model that allows finding records in database with easy. JRails drops Prototype JavaScript library support in favor of jQuery [12,13]. Formtastic creates helper methods for HTML forms and automatically generates necessary fields that are semantically valid. Also supports model relationships and implements advanced internationalization methods. Inherited Resource easy REST support for Rails application. This plugin extend Rails with module that automatically adds methods to controller class that create, read, update and delete resources no additional code is required. Responders small extension that add necessary headers to sessions and HTTP headers when adding, updating or deleting database records. Required by Inherited Resources.
V. FRONT END
Front end of our application was created in HTML 5 [11] - fairly new standard, which is slowly replacing its predecessors (HTML 4.01 and XHTML 1.1) [18]. It is still under development, however current browsers already support most of its features. HTML 5 is much more elastic and implements a lot of new tags and attributes but most important makes browser independent from third party plugins used to play audio or video (required codecs are now built-in). In order to simplify HTML creation process a different markup language was used Haml [12]. It is an abstract description of (X)HTML along with some helpers that allow to create dynamic content. Haml greatly simplifies the process of HTML writing and the created code is even up to 50% smaller, as shown on Figure 4 and Figure 5.
#box .title %h1 = link_to @title, page_url .content %p= render :partial => 'box_content' Fig. 4 Example Haml code
<div id="box"> <div class="title"> <h1><%= link_to @title, page_url %></h1> </div> <div class="content"> <p><%= render :partial => 'box_content' %></p> </div> </div>
Fig. 5 Example HTML code
In order to better understand the full capability of rails plugins in the Figure 6 a simple controller class is shown.
class CustomersController < InheritedResources::Base before_filter :check_account, :only => [:show, :edit, :update, :destroy] before_filter :require_user respond_to :js, :only => [:index] end Fig. 6 Source code of customers controller
It is very easy to notice that Haml code takes less space and uses very few special characters. Along with HTML we will also use Cascading Style Sheet (CSS) to separate page content from presentation details. On top of it we will use jQuery - JavaScript library that will allow to add some dynamic effects to website, like dropdown menus and simple AJAX features [22].
This small piece of code is responsible for all operations run on customer records create, read, update and delete no coding is needed thanks to its parent class from Inherited Resources plugin. Besides that it also call methods used to validate user and its access before running record-based methods and makes sure that index action will respond to JavaScript requests (used in AJAX - based record filters).
VII. SUMMARY
The main purpose of created application was to show that Ruby on Rails is a real competition for currently most popular PHP language and its frameworks. Even though less then 5% of sites use Ruby it is stable and supported enough to be capable of running big commercial projects thanks to one of its main advantages - speed. Even though in benchmarks the efficiently of different Ruby implementations is substantial [15], its still a lot faster then PHP. A few of most
369 popular Ruby project include Twitter or Dig social networks or widely used business solutions offered by 37 Signals Basecamp and Campfire. Although Ruby and Rails are available for Microsoft Windows it is still best supported in Unix operating systems like Linux or MacOS X thanks to command-line utility called gem. Created application was developed with Firefox, Safari and Internet Explorer in mind and works seamlessly under desktop computers as well as mobile systems like iOS and Android. Example integration can be easily created using built-in API support in designed application. E-commerce stores or any other application that allows for XML integration can be synchronized. This approach did not create much of additional work. In fact it was a matter of adding a few new template files and some additional logic to controllers. Everything else was handled directly by Rails framework core components. Ruby language might be hard for people that are used to imperative programming languages (like C/C++ or Java), as its core language constructions are a bit different and so is approach to some problems. Nonetheless after reading some popular books and tutorials [16,17] most of the people will appreciate what it has to offer and how much easier and faster programming can be. [13] Prototype http://www.prototypejs.org/ JavaScript framework,
[14] jQuery, http://www.jquery.com/ [15] The Great Ruby Shootout (July 2010), http://programmingzen.com/2010/07/19/the-great-rubyshootout-july-2010/ [16] Sam Ruby, Dave Thomas, David Heinemeier Hannson, Agile Web Development With Rails 3rd Edition, The Pragmatic Bookshelf, June 2008 [17] Ruby in Twenty Minutes, lang.org/en/documentation/quickstart/4/ http://www.ruby-
[18] Sakowicz B., Wjtowski M., Zalewski P., Napieralski A., Problems of Standardization in Web Technologies XI Konferencja Sieci i Systemy Informatyczne, d, padziernik 2003, pp. 111-114, ISBN 83-88742-91-4 [19] Wilk S., Sakowicz B., Napieralski A., Wdraanie aplikacji J2EE w oparciu o serwer Tomcat 5.0 i baz danych MySQL SIS XII Konferencja, d padziernik 2004, pp.379-386, ISBN 83-7415-042-4 [20] Wojciechowski J., Sakowicz B., Dura K., Napieralski A., MVC model struts framework and file upload issues in web applications based on J2EE platform TCSET2004, 2428 Feb. 2004, Lviv, Ukraine, pp., 342-345 , ISBN 966-553380-0 [21] Ziemniak P., Sakowicz B., Napieralski A.: "Object oriented application cooperation methods with relational database (ORM) based on J2EE Technology"; CADSM'2007; ISBN 978-966-553-587-4 [22] Cisz, M.; Zabierowski, W.: "Community services portal based on the campus of Technical University of Lodz. Using Ajax technology".; TCSET 2010 , Page(s): 183 - 184; ISBN 978-966-553-875-2 [23] Murlewski J., Kowalski T., Adamus R., Sakowicz B., Napieralski A., Query Optimization in Grid Databases, 14th International Conference Mixed Design of Integrated Circuits and Systems MIXDES 2007, 21-23, str. 707-710, ISBN 83922632-4-3
ACKNOWLEDGEMENTS
This research was supported by the Technical University of Lodz.
REFERENCES
[1] PHP Frameworks, http://www.phpframeworks.com/ [2] Django project, http://www.djangoproject.com/ [3] Ruby on Rails, http://rubyonrails.org/ [4] Phusion Passenger, http://www.modrails.com/ [5] NIST Computer Security Division Cloud Computing, http://csrc.nist.gov/groups/SNS/cloud-computing/ [6] Roy Fieldings Dissertation, Chapter 5, http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_s tyle.htm [7] RFC 2616 HTTP/1.1, http://tools.ietf.org/html/rfc2616 [8] ActiveRecord, http://api.rubyonrails.org/classes/ActiveRecord/Base.html [9] MySQL 5 Storage Engines http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html [10] MySQL 5.1 Numeric Types http://dev.mysql.com/doc/refman/5.1/en/numeric-typeoverview.html [11] W3C HTML5 http://www.w3.org/TR/html5/ Specification,