Ruby on rails RAD

Uploaded on


More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Ruby on Rails Rapid Application DevelopmentPetronela-Alina DănilăAndreea- Mădălina Lazăr
  • 2. Table of contents 1. Introduction 2. Overview 3. Architecture 3.1. Rails modules 3.2. MVC pattern 4. Application example 4.1. Creating a project 4.2. Creating a controller 4.3. Creating a view 5. Comparisons 6. Conclusions 7. Bibliography
  • 3. 1. Introduction We decided to choose as a development environment Ruby on Rails because we feltthe need in challenging our selves and learn something new in a short period of time. This paper covers the steps of developing a Ruby On Rails web application includingtheory and practical work. We start of by pointing the language used, framework and RADthat we used, including small technical details. Further we present the architecture of the Rad that we have chosen, a small glimpse atit’s architecture and after that shortly pointing out the modules In the Application Example module we present a path in creating a web applicationusing Ruby on Rails: creating a new project, controller and view and describing some of theframework’s features involving the method that we used in development. To close it all we propose a chapter of comparisons between Rails, Ruby on Rails andother frameworks, RAD’s with pro’s and cont’s.
  • 4. 2. OverviewRuby Is a general purpose, cross platform programming language. It supports multipleparadigms, including functional, object oriented, imperative and reflective. The language isinterpreted and dynamic typed, having automatic memory management. Ruby was designedto have an elegant syntax and made as human readable as possible.Rails Is an open source web application framework written in the Ruby programminglanguage, based on the Model-View-Controller pattern.Ruby on Rails (RoR) The framework includes tools that make web development easier, and it was createdas a response to heavy web frameworks as J2EE and .NET. In order to make the development faster, Ruby on Rails uses coding by conventionand assumptions, eliminating configuration code. Many of the common tasks for web development are built-in in the framework,including email management, object database mappers, file structure, code generation,elements naming and organization and so on. Ruby on Rails framework has the following features: ● Model-View-Controller architecture ● REST for web services ● Support for major databases (MySQL, Oracle, MS SQL Server, PostgresSQL, IBM DB2) ● Convention over configuration ● Script generators ● YAML machine, for human readable data serialization ● Extensive use of javascript libraries
  • 5. 3. Architecture Figure 1. Overall framework architecture3.1. Rails modulesAction Mailer Is the module responsible for providing e-mail services. It handles incoming andoutgoing mails, using simple text or rich-format emails. It has common built-in as welcomemessages or sending forgotten passwords.Action Pack Provides the controller and view layers of the MVC pattern. This module captures theuser requests made by the browser/ client and maps the requests to the actions defined in thecontroller layer. After the action is executed, a view is rendered to be displayed in browser. This module contains 3 sub-modules: ● Action Dispatch - handles the routing of the request (dispatching); ● Action Controller - the request is routed to the corresponding controller, which contains actions to control the model and view, as well as managing user sessions; ● Action View - renders the representation of the web page, which can be made from templates, feeds and other presentation formats.
  • 6. Active Model Represents the interface between Action Pack and Active Record.Active Record Is used to manage data in relational databases through objects. This module connectsthe database tables with the representation in Ruby classes. Rails provide CRUDfunctionality with zero configuration.Active Resource This module manages the connection between RESTful web services and objects. Itmaps model classes to remote REST resources.Active Support Represents the collection of utility classes and standard Ruby libraries.Railties Is the core of Rails framework that connects all the modules and handles all processes.3.2. MVC patternModel This layer represents the business logic of the application. Usually, the models arebacked by database, but they can also be ordinary Ruby classes that implement a set ofinterfaces provided by Active Model.View Is the front-end of the application. The views are HTML files with embedded Rubycode (.erb files). They usually contain loops and conditionals, displaying data received fromthe controller.Controller This layer is responsible for handling incoming HTTP requests. The controllerinteracts with models and views by manipulating the model and rendering the view. Theyprocess data from models and pass it to view.
  • 7. 4. Application example Before development, you must first install Ruby on Rails ( and find an IDE (RubyMine, Eclipse, NetBeans, RubyInSteel, RadRails). As an example, we propose an application that gathers information from three webservices:, and for a user givenquery.4.1. Creating a project This can be made using the IDE or running a command in the console. All theprojects have the same structure, with the file structure containing directories for models,views, controllers and configuration files. An important configuration file is routes.rb, which specifies the application routing:get "home/index"get "home/respond"4.2. Creating a controller In Ruby on Rails, a Controller is a class inheriting ApplicationController:(class HomeController < ApplicationController), that contains a number of predefinedmethods equaly ( regarding both the name and the number) to the number and name of theapplication’s views. Calling REST services The default method is using the standard Ruby RestClient. # create the request query_params = {:api_key => SLIDESHARE_KEY, :ts => ts, :hash => hash, :q => query, :page => 1, :items_per_page => SLIDESHARE_MAX_COUNT} response = RestClient.get(SLIDESHARE_SEARCH_URL, :params => query_params)4.3. Creating a view A view is mapped to a method in the controller, as specified in the routing file. Whena page is requested, the corresponding controller handles the request (if necessary interactswith the model) and passes the control to the view.In our example, we have the respond method, that is mapped to the respond view. def respond if !params["query"].nil? @slideshare = slideshare_get (params["query"]) @twitter = twitter_get (params["query"]) @event = eventbrite_get (params["query"])
  • 8. end end To better ensure the quality of reading, under the params hash variable, you can findthe data sent by the user, from your controller. There are two types of parameters: the first areas part of your URL(everything after “?” in your URL), and the second type the ones sentfrom a POST request. Usually views, in RoR are html.erb documents. They use the html format in order torender text visually in the browser, and the .erb extension in order to bind the Rails instancevariables that holds information from the controller and shares it with the current view. Thecontent of these variables can be used by embedding the <% %> and <%= %> tags. In this example : <% index = 0%> <%@slideshare.each do |p| %> <li id =slides_<%=index%>><%= image_tag p.thumbnail, :class => "thumbnail" %><p class="titles"><%=p.title%></p></li> <% index= index+1%> <% end %>you can see the usage of both these tags. The difference between the two is that the one usingthe “=” sign actually puts the value of the variable inside the statement, whereas the otherone simply resembles and embeds Ruby code. Another thing that you can spot from the statement above is the usage of <%=image tag %>. This is one of the many helper methods that Rails comes to thedeveloper’s aid in that it replaces bulks of html code with one easy and intuitive call. Thesekind of helpers can be used for forms(<%= form_tag %>), links (<%= link_to %>),images(as above), meta tags( link tag for css - <%= stylesheet_link_tag "main" %>, <%=csrf_meta_tags %>), scripts( <%= javascript_include_tag "application" %>).
  • 9. 5. Comparisons Figure 2. Rails vs PHP vs Java Figure 3. Google trends, search comparisonWhy use Ruby on Rails: ● Ruby is more elegant than other languages ● quicker launch - it could take about half of the development time with other frameworks ● easier changes - future modifications can be made more quickly ● convenient plugins ● code testingWhen to use Ruby on Rails
  • 10. ● e-commerce ● membership sites - this option is built-in in Rails and there are a variety of plugins ● content management ● custom database solutionsWhy not to use Ruby (on Rails) ● Ruby is slow ● Ruby is new ● not very scalable
  • 11. 6. Conclusions Since the first version was launched, Ruby on Rails has received widespread support,especially from the open-source community. It’s purpose is rapid application developmentand AGILE practices. The framework architecture meets most of it’s intended goals, but not without anyflaws. “Ruby is optimized for programmer happiness and sustainable productivity”.
  • 12. 7. Bibliography,+ruby+on+rails,+cakephp,+django+python,