SlideShare uma empresa Scribd logo
1 de 12
Baixar para ler offline
Ruby on Rails
           Rapid Application Development




Petronela-Alina Dănilă
Andreea- Mădălina Lazăr
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
1. Introduction

         We decided to choose as a development environment Ruby on Rails because we felt
the 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 including
theory and practical work. We start of by pointing the language used, framework and RAD
that we used, including small technical details.
         Further we present the architecture of the Rad that we have chosen, a small glimpse at
it’s architecture and after that shortly pointing out the modules
         In the Application Example module we present a path in creating a web application
using Ruby on Rails: creating a new project, controller and view and describing some of the
framework’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 and
other frameworks, RAD’s with pro’s and cont’s.
2. Overview

Ruby
        Is a general purpose, cross platform programming language. It supports multiple
paradigms, including functional, object oriented, imperative and reflective. The language is
interpreted and dynamic typed, having automatic memory management. Ruby was designed
to have an elegant syntax and made as human readable as possible.

Rails
       Is an open source web application framework written in the Ruby programming
language, based on the Model-View-Controller pattern.

Ruby on Rails (RoR)
        The framework includes tools that make web development easier, and it was created
as a response to heavy web frameworks as J2EE and .NET.
        In order to make the development faster, Ruby on Rails uses coding by convention
and 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
3. Architecture




                          Figure 1. Overall framework architecture


3.1. Rails modules

Action Mailer
       Is the module responsible for providing e-mail services. It handles incoming and
outgoing mails, using simple text or rich-format emails. It has common built-in as welcome
messages or sending forgotten passwords.

Action Pack
        Provides the controller and view layers of the MVC pattern. This module captures the
user requests made by the browser/ client and maps the requests to the actions defined in the
controller 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.
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 connects
the database tables with the representation in Ruby classes. Rails provide CRUD
functionality with zero configuration.

Active Resource
       This module manages the connection between RESTful web services and objects. It
maps 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 pattern

Model
        This layer represents the business logic of the application. Usually, the models are
backed by database, but they can also be ordinary Ruby classes that implement a set of
interfaces provided by Active Model.

View
        Is the front-end of the application. The views are HTML files with embedded Ruby
code (.erb files). They usually contain loops and conditionals, displaying data received from
the controller.

Controller
        This layer is responsible for handling incoming HTTP requests. The controller
interacts with models and views by manipulating the model and rendering the view. They
process data from models and pass it to view.
4. Application example

       Before development, you must first install Ruby on Rails (http://rubyonrails.org/
download) and find an IDE (RubyMine, Eclipse, NetBeans, RubyInSteel, RadRails).
       As an example, we propose an application that gathers information from three web
services: www.slideshare.net, www.eventbrite.com and www.twitter.com for a user given
query.

4.1. Creating a project
        This can be made using the IDE or running a command in the console. All the
projects 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 predefined
methods equaly ( regarding both the name and the number) to the number and name of the
application’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. When
a page is requested, the corresponding controller handles the request (if necessary interacts
with 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"])
end
                  end

        To better ensure the quality of reading, under the params hash variable, you can find
the data sent by the user, from your controller. There are two types of parameters: the first are
as part of your URL(everything after “?” in your URL), and the second type the ones sent
from a POST request.
        Usually views, in RoR are html.erb documents. They use the html format in order to
render text visually in the browser, and the .erb extension in order to bind the Rails instance
variables that holds information from the controller and shares it with the current view. The
content 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 using
the “=” sign actually puts the value of the variable inside the statement, whereas the other
one 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 the
developer’s aid in that it replaces bulks of html code with one easy and intuitive call. These
kind 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" %>).
5. Comparisons




                            Figure 2. Rails vs PHP vs Java




                     Figure 3. Google trends, search comparison

Why 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 testing

When to use Ruby on Rails
●   e-commerce
   ●   membership sites - this option is built-in in Rails and there are a variety of plugins
   ●   content management
   ●   custom database solutions

Why not to use Ruby (on Rails)
  ● Ruby is slow
  ● Ruby is new
  ● not very scalable
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 development
and AGILE practices.
       The framework architecture meets most of it’s intended goals, but not without any
flaws.


       “Ruby is optimized for programmer happiness and sustainable productivity”.
7. Bibliography

http://rubyonrails.org/
http://en.wikipedia.org/wiki/Ruby_on_Rails#Technical_overview
http://www.adrianmejiarosario.com/content/ruby-rails-architectural-design
http://www.slideshare.net/jonkinney/ruby-on-rails-overview
http://en.wikipedia.org/wiki/Ruby_%28programming_language%29
https://github.com/rails/rails
http://en.wikipedia.org/wiki/Comparison_of_Web_application_frameworks
http://en.wikipedia.org/wiki/Ruby_on_Rails
http://en.wikipedia.org/wiki/Convention_over_Configuration
https://picasaweb.google.com/Dikiwinky/Ruby#5116531304417868130
http://www.slideshare.net/dosire/when-to-use-ruby-on-rails-1308900
http://on-ruby.blogspot.com/2006/11/tim-bray-comparing-intrisics.html
http://www.google.com/trends?
q=symfony,+ruby+on+rails,+cakephp,+django+python,+asp.net+mvc&ctab=0&geo=all&
date=all&sort=3

Mais conteúdo relacionado

Mais procurados

Rails
RailsRails
RailsSHC
 
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRISThe glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRISGeert Pante
 
Spring HATEOAS
Spring HATEOASSpring HATEOAS
Spring HATEOASYoann Buch
 
Session 37 - JSP - Part 2 (final)
Session 37 - JSP - Part 2 (final)Session 37 - JSP - Part 2 (final)
Session 37 - JSP - Part 2 (final)PawanMM
 
Session 36 - JSP - Part 1
Session 36 - JSP - Part 1Session 36 - JSP - Part 1
Session 36 - JSP - Part 1PawanMM
 
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web AppsSession 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web AppsPawanMM
 
Java Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkJava Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkGuo Albert
 
Session 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design PatternsSession 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design PatternsPawanMM
 
[Laptrinh.vn] lap trinh Spring Framework 3
[Laptrinh.vn] lap trinh Spring Framework 3[Laptrinh.vn] lap trinh Spring Framework 3
[Laptrinh.vn] lap trinh Spring Framework 3Huu Dat Nguyen
 
Angular jS Introduction by Google
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by GoogleASG
 
Annotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCAnnotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCJohn Lewis
 
Approaches to machine actionable links
Approaches to machine actionable linksApproaches to machine actionable links
Approaches to machine actionable linksStephen Richard
 
Session 33 - Session Management using other Techniques
Session 33 - Session Management using other TechniquesSession 33 - Session Management using other Techniques
Session 33 - Session Management using other TechniquesPawanMM
 
Session 32 - Session Management using Cookies
Session 32 - Session Management using CookiesSession 32 - Session Management using Cookies
Session 32 - Session Management using CookiesPawanMM
 
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE  AND JSP PROCESSINGINTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE  AND JSP PROCESSING
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSINGAaqib Hussain
 

Mais procurados (19)

Rails
RailsRails
Rails
 
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRISThe glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
 
Spring HATEOAS
Spring HATEOASSpring HATEOAS
Spring HATEOAS
 
Session 37 - JSP - Part 2 (final)
Session 37 - JSP - Part 2 (final)Session 37 - JSP - Part 2 (final)
Session 37 - JSP - Part 2 (final)
 
Rest
Rest Rest
Rest
 
Intro lift
Intro liftIntro lift
Intro lift
 
Session 36 - JSP - Part 1
Session 36 - JSP - Part 1Session 36 - JSP - Part 1
Session 36 - JSP - Part 1
 
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web AppsSession 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
 
Java Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkJava Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC Framework
 
Session 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design PatternsSession 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design Patterns
 
[Laptrinh.vn] lap trinh Spring Framework 3
[Laptrinh.vn] lap trinh Spring Framework 3[Laptrinh.vn] lap trinh Spring Framework 3
[Laptrinh.vn] lap trinh Spring Framework 3
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Angular jS Introduction by Google
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by Google
 
Annotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCAnnotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVC
 
Approaches to machine actionable links
Approaches to machine actionable linksApproaches to machine actionable links
Approaches to machine actionable links
 
Session 33 - Session Management using other Techniques
Session 33 - Session Management using other TechniquesSession 33 - Session Management using other Techniques
Session 33 - Session Management using other Techniques
 
Spring
SpringSpring
Spring
 
Session 32 - Session Management using Cookies
Session 32 - Session Management using CookiesSession 32 - Session Management using Cookies
Session 32 - Session Management using Cookies
 
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE  AND JSP PROCESSINGINTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE  AND JSP PROCESSING
INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING
 

Semelhante a Ruby on rails RAD

Ruby Rails Web Development
Ruby Rails Web DevelopmentRuby Rails Web Development
Ruby Rails Web DevelopmentSonia Simi
 
Ruby On Rails Siddhesh
Ruby On Rails SiddheshRuby On Rails Siddhesh
Ruby On Rails SiddheshSiddhesh Bhobe
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorialsunniboy
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Railsanides
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Railscodeinmotion
 
Jasig Rubyon Rails
Jasig Rubyon RailsJasig Rubyon Rails
Jasig Rubyon RailsPaul Pajo
 
Lecture #5 Introduction to rails
Lecture #5 Introduction to railsLecture #5 Introduction to rails
Lecture #5 Introduction to railsEvgeniy Hinyuk
 
Introduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukIntroduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukPivorak MeetUp
 
Principles of MVC for Rails Developers
Principles of MVC for Rails DevelopersPrinciples of MVC for Rails Developers
Principles of MVC for Rails DevelopersEdureka!
 
Ruby On Rails Basics
Ruby On Rails BasicsRuby On Rails Basics
Ruby On Rails BasicsAmit Solanki
 
Ruby on Rails introduction
Ruby on Rails introduction Ruby on Rails introduction
Ruby on Rails introduction Tran Hung
 
Introducing Ruby/MVC/RoR
Introducing Ruby/MVC/RoRIntroducing Ruby/MVC/RoR
Introducing Ruby/MVC/RoRSumanth krishna
 
Beginners' guide to Ruby on Rails
Beginners' guide to Ruby on RailsBeginners' guide to Ruby on Rails
Beginners' guide to Ruby on RailsVictor Porof
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantNitin Sawant
 

Semelhante a Ruby on rails RAD (20)

Ruby Rails Web Development
Ruby Rails Web DevelopmentRuby Rails Web Development
Ruby Rails Web Development
 
Rails interview questions
Rails interview questionsRails interview questions
Rails interview questions
 
Ruby On Rails Siddhesh
Ruby On Rails SiddheshRuby On Rails Siddhesh
Ruby On Rails Siddhesh
 
Aspose pdf
Aspose pdfAspose pdf
Aspose pdf
 
Ruby on rails for beginers
Ruby on rails for beginersRuby on rails for beginers
Ruby on rails for beginers
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorial
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
 
Ruby on Rails
Ruby on RailsRuby on Rails
Ruby on Rails
 
Laravel overview
Laravel overviewLaravel overview
Laravel overview
 
Jasig Rubyon Rails
Jasig Rubyon RailsJasig Rubyon Rails
Jasig Rubyon Rails
 
Lecture #5 Introduction to rails
Lecture #5 Introduction to railsLecture #5 Introduction to rails
Lecture #5 Introduction to rails
 
Introduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukIntroduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy Hinyuk
 
Principles of MVC for Rails Developers
Principles of MVC for Rails DevelopersPrinciples of MVC for Rails Developers
Principles of MVC for Rails Developers
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Ruby On Rails Basics
Ruby On Rails BasicsRuby On Rails Basics
Ruby On Rails Basics
 
Ruby on Rails introduction
Ruby on Rails introduction Ruby on Rails introduction
Ruby on Rails introduction
 
Introducing Ruby/MVC/RoR
Introducing Ruby/MVC/RoRIntroducing Ruby/MVC/RoR
Introducing Ruby/MVC/RoR
 
Beginners' guide to Ruby on Rails
Beginners' guide to Ruby on RailsBeginners' guide to Ruby on Rails
Beginners' guide to Ruby on Rails
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin Sawant
 

Último

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Ruby on rails RAD

  • 1. Ruby on Rails Rapid Application Development Petronela-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 felt the 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 including theory and practical work. We start of by pointing the language used, framework and RAD that we used, including small technical details. Further we present the architecture of the Rad that we have chosen, a small glimpse at it’s architecture and after that shortly pointing out the modules In the Application Example module we present a path in creating a web application using Ruby on Rails: creating a new project, controller and view and describing some of the framework’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 and other frameworks, RAD’s with pro’s and cont’s.
  • 4. 2. Overview Ruby Is a general purpose, cross platform programming language. It supports multiple paradigms, including functional, object oriented, imperative and reflective. The language is interpreted and dynamic typed, having automatic memory management. Ruby was designed to have an elegant syntax and made as human readable as possible. Rails Is an open source web application framework written in the Ruby programming language, based on the Model-View-Controller pattern. Ruby on Rails (RoR) The framework includes tools that make web development easier, and it was created as a response to heavy web frameworks as J2EE and .NET. In order to make the development faster, Ruby on Rails uses coding by convention and 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 architecture 3.1. Rails modules Action Mailer Is the module responsible for providing e-mail services. It handles incoming and outgoing mails, using simple text or rich-format emails. It has common built-in as welcome messages or sending forgotten passwords. Action Pack Provides the controller and view layers of the MVC pattern. This module captures the user requests made by the browser/ client and maps the requests to the actions defined in the controller 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 connects the database tables with the representation in Ruby classes. Rails provide CRUD functionality with zero configuration. Active Resource This module manages the connection between RESTful web services and objects. It maps 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 pattern Model This layer represents the business logic of the application. Usually, the models are backed by database, but they can also be ordinary Ruby classes that implement a set of interfaces provided by Active Model. View Is the front-end of the application. The views are HTML files with embedded Ruby code (.erb files). They usually contain loops and conditionals, displaying data received from the controller. Controller This layer is responsible for handling incoming HTTP requests. The controller interacts with models and views by manipulating the model and rendering the view. They process data from models and pass it to view.
  • 7. 4. Application example Before development, you must first install Ruby on Rails (http://rubyonrails.org/ download) and find an IDE (RubyMine, Eclipse, NetBeans, RubyInSteel, RadRails). As an example, we propose an application that gathers information from three web services: www.slideshare.net, www.eventbrite.com and www.twitter.com for a user given query. 4.1. Creating a project This can be made using the IDE or running a command in the console. All the projects 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 predefined methods equaly ( regarding both the name and the number) to the number and name of the application’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. When a page is requested, the corresponding controller handles the request (if necessary interacts with 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 find the data sent by the user, from your controller. There are two types of parameters: the first are as part of your URL(everything after “?” in your URL), and the second type the ones sent from a POST request. Usually views, in RoR are html.erb documents. They use the html format in order to render text visually in the browser, and the .erb extension in order to bind the Rails instance variables that holds information from the controller and shares it with the current view. The content 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 using the “=” sign actually puts the value of the variable inside the statement, whereas the other one 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 the developer’s aid in that it replaces bulks of html code with one easy and intuitive call. These kind 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 comparison Why 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 testing When 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 solutions Why 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 development and AGILE practices. The framework architecture meets most of it’s intended goals, but not without any flaws. “Ruby is optimized for programmer happiness and sustainable productivity”.
  • 12. 7. Bibliography http://rubyonrails.org/ http://en.wikipedia.org/wiki/Ruby_on_Rails#Technical_overview http://www.adrianmejiarosario.com/content/ruby-rails-architectural-design http://www.slideshare.net/jonkinney/ruby-on-rails-overview http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 https://github.com/rails/rails http://en.wikipedia.org/wiki/Comparison_of_Web_application_frameworks http://en.wikipedia.org/wiki/Ruby_on_Rails http://en.wikipedia.org/wiki/Convention_over_Configuration https://picasaweb.google.com/Dikiwinky/Ruby#5116531304417868130 http://www.slideshare.net/dosire/when-to-use-ruby-on-rails-1308900 http://on-ruby.blogspot.com/2006/11/tim-bray-comparing-intrisics.html http://www.google.com/trends? q=symfony,+ruby+on+rails,+cakephp,+django+python,+asp.net+mvc&ctab=0&geo=all& date=all&sort=3