Ruby on Rails. Object Oriented Analysis & Design CSCI-5448 University of Colorado, Boulder. -Dheeraj Potlapally



Similar documents
Ruby on Rails is a web application framework written in Ruby, a dynamically typed programming language The amazing productivity claims of Rails is

Ruby On Rails. CSCI 5449 Submitted by: Bhaskar Vaish

Ruby on Rails. a high-productivity web application framework. blog.curthibbs.us/ Curt Hibbs <curt@hibbs.com>

Web Development Frameworks

Ruby on Rails Secure Coding Recommendations

Web Frameworks. web development done right. Course of Web Technologies A.A. 2010/2011 Valerio Maggio, PhD Student Prof.

INTERNET PROGRAMMING AND DEVELOPMENT AEC LEA.BN Course Descriptions & Outcome Competency

WEB APPLICATION DEVELOPMENT. UNIT I J2EE Platform 9

Specialized Programme on Web Application Development using Open Source Tools

Agile Web Development with Rails 4

Rapid Application Development. and Application Generation Tools. Walter Knesel

Pete Helgren Ruby On Rails on i

10CS73:Web Programming

Grails 1.1. Web Application. Development. Reclaiming Productivity for Faster. Java Web Development. Jon Dickinson PUBLISHING J MUMBAI BIRMINGHAM


BEST WEB PROGRAMMING LANGUAGES TO LEARN ON YOUR OWN TIME

D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to:

Building Views and Charts in Requests Introduction to Answers views and charts Creating and editing charts Performing common view tasks

OCR LEVEL 3 CAMBRIDGE TECHNICAL

The end. Carl Nettelblad

Short notes on webpage programming languages

Specialized Programme on Web Application Development using Open Source Tools

Complete Java Web Development

DIPLOMA IN WEBDEVELOPMENT

This three-day instructor-led course provides students with the tools to extend Microsoft Dynamics CRM 4.0.

THE ROAD TO CODE. ANDROID DEVELOPMENT IMMERSIVE May 31. WEB DEVELOPMENT IMMERSIVE May 31 GENERAL ASSEMBLY

The Great Office 365 Adventure

Course Number: IAC-SOFT-WDAD Web Design and Application Development

JVA-122. Secure Java Web Development

Rails Cookbook. Rob Orsini. O'REILLY 8 Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo

GOA365: The Great Office 365 Adventure

J j enterpririse. Oracle Application Express 3. Develop Native Oracle database-centric web applications quickly and easily with Oracle APEX

Chapter 13 Computer Programs and Programming Languages. Discovering Computers Your Interactive Guide to the Digital World

What s really under the hood? How I learned to stop worrying and love Magento

Building Dynamic Websites With the MVC Pattern. ACM UIUC, 2010

Outline. Lecture 18: Ruby on Rails MVC. Introduction to Rails

Web Cloud Architecture

ASP.NET MVC Secure Coding 4-Day hands on Course. Course Syllabus

Check list for web developers

ActiveVOS Server Architecture. March 2009

LAMP [Linux. Apache. MySQL. PHP] Industrial Implementations Module Description

Web Application Vulnerability Testing with Nessus

Modern Software Development Tools on OpenVMS

Bubble Code Review for Magento

Thomas Röthlisberger IT Security Analyst

Finding and Preventing Cross- Site Request Forgery. Tom Gallagher Security Test Lead, Microsoft

REDCap General Security Overview

Accessing Data with ADOBE FLEX 4.6

Extending Microsoft Dynamics CRM 4.0

Adobe Systems Incorporated

Developing ASP.NET MVC 4 Web Applications MOC 20486

5 Mistakes to Avoid on Your Drupal Website

Leveraging existing Web frameworks for a SIOC explorer to browse online social communities

An Oracle White Paper June Security and the Oracle Database Cloud Service

Web Development using PHP (WD_PHP) Duration 1.5 months

Adam Rauch Partner, LabKey Software Extending LabKey Server Part 1: Retrieving and Presenting Data

End User Guide The guide for /ftp account owner

SOA, case Google. Faculty of technology management Information Technology Service Oriented Communications CT30A8901.

Web Pages. Static Web Pages SHTML

FileMaker Server 9. Custom Web Publishing with PHP

<Insert Picture Here> Oracle Application Express 4.0

WHITE PAPER. FortiWeb and the OWASP Top 10 Mitigating the most dangerous application security threats

Security features of ZK Framework

Oracle Application Express MS Access on Steroids

ASP.NET MVC. in Action JEFFREY PALERMO JIMMY BOGARD BEN SCHEIRMAN MANNING. (74 w. long.) WITH MVCCONTRIB, N HIBERNATE, AND MORE.

Seamless Web Data Entry for SAS Applications D.J. Penix, Pinnacle Solutions, Indianapolis, IN

A benchmark approach to analyse the security of web frameworks

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

Safewhere*Identify 3.4. Release Notes

Design and Functional Specification

How To Build A Web App

Q&A for Zend Framework Database Access

Java 7 Recipes. Freddy Guime. vk» (,\['«** g!p#« Carl Dea. Josh Juneau. John O'Conner

Portals and Hosted Files

Where every interaction matters.

MarkLogic Server. Reference Application Architecture Guide. MarkLogic 8 February, Copyright 2015 MarkLogic Corporation. All rights reserved.

XML Processing and Web Services. Chapter 17

A Framework for Service-Oriented Extensions to Ruby on Rails

Certified PHP/MySQL Web Developer Course

IDEALX Management Console. > Goals & motivations > IMC for sysadmins > IMC for developers > Roadmap & community

MatchPoint Technical Features Tutorial Colygon AG Version 1.0

Developing ASP.NET MVC 4 Web Applications

Slides from INF3331 lectures - web programming in Python

Pro<DOC/> e-commerce Technology An Introduction

1. Introduction. 2. Web Application. 3. Components. 4. Common Vulnerabilities. 5. Improving security in Web applications

The Learn-Verified Full Stack Web Development Program

HTML5. Turn this page to see Quick Guide of CTTC

Secure Authentication and Session. State Management for Web Services

Credits: Some of the slides are based on material adapted from

Business Application Services Testing

Transcription:

Ruby on Rails Object Oriented Analysis & Design CSCI-5448 University of Colorado, Boulder -Dheeraj Potlapally

INTRODUCTION Page 1

What is Ruby on Rails Ruby on Rails is a web application framework written in Ruby. David Heinemeier Hansson developed it in 2003. Since then Improvised by Rails Core Team. Released in 2004 termed as RoR. Works on Windows, Macintosh, Linux. Compatible to all common databases. Page 2

What else are available in Market Many other frameworks exist in market and more importantly many other languages for web development are available. Python-TurboGears, WebPy, Django Java-JSP/Servlets, Struts PHP-Symfony Page 3

Why again a new tool?(1) Fast Development and Prototyping Old Techniques: When developing website for a client there may be issues like creating specific to clients domain which would slow down the development process. RoR: Uses a concept called Convention over Configuration which leaves with little configuration while writing the code. Page 4

Why again a new tool?(2) Structured Code and Neat Markup Old Techniques: Problem here is separating the view markup from business logic. Asp and PHP applications have business logic code scattered throughout HTML. This also makes code hard to maintain. RoR: Rails uses MVC (model-view-controller) compound design pattern to solve this problem. By using MVC we have a clean, structured code, which is easily maintainable and very flexible. Page 5

Why again a new tool?(3) Interchangeable Databases Old Techniques: Once the website is build using MySQL and suppose there is a change in decision and we need to use Sybase or Oracle. Then the problem of rewriting the code comes in since the embedded SQL Query strings are scattered in our code. RoR: Ruby on Rails is Database independent, meaning we can make only few configuration changes and we can start using Microsoft SQL, Oracle etc. Page 6

Why again a new tool?(4) Database Schema Control Old Techniques: When working in a big group unexpected changes to database may occur by other people because of old revision of scema. RoR: This problem is solved by a method called Migrations. When changes are made, fellow developers can run a simple command and they will be on the latest version of the database. Migrations are basically version control for the database schema. Page 7

FEATURES OF RUBY Page 8

What is Ruby It is an Object-Oriented and Dynamic Programming Language. Written in 1995 by Yukihiro Matsumoto. Influenced by Python, Perl and Lisp. Easy to understand and work with. Simple syntax. Powerful dynamic features and metaprogramming capabilities. Page 9

Ruby is Truly Object-Oriented All classes derived from Object including Class (like Java) but there are no primitives (not like Java at all) Ruby uses single-inheritance. Mixins give the power of multiple inheritance. Modules allow addition of behaviors to a class. Reflection is built in along with lots of other highly dynamic metadata features. Memory management via garbage collector as in Java. Overall we can think it as a programmer friendly language with strong capabilities. Page 10

Dynamic Programming Duck Typing Based on signatures, not class inheritance Dynamic Dispatch A key concept of OOP: methods are actually messages that are sent to an object instance Dynamic Behavior Reflection Scope Reopening (Kind of like AOP) Eval Breakpoint debugger Page 11

RAILS IN A NUTSHELL Page 12

Features of Rails in Detail(1) Full Stack MVC Framework: Rails is an MVC (model, view, controller) framework where Rails provides all the layers and they work together seamlessly. Other frameworks often implement only part of the solution, requiring the developer to integrate multiple frameworks into the application and then coerce them into working together. (For example, a Java developer might use Hibernate, Struts, and Tiles to get full MVC support.) Page 13

Features of Rails in Detail(2) Convention over Configuration Convention over configuration means an end to verbose XML configuration files--in Rails, there aren't any! Instead of XML sit-ups, a Rails application uses a few simple programming conventions that allow it to figure everything out through reflection and discovery. For example, Rails uses intelligent reflection to automatically map database tables to Ruby objects. Page 14

Features of Rails in Detail(3) Scaffolding Rails can automatically create a full set of CRUD (Create, Retrieve, Update, and Delete) operations and views on any database table. This scaffolding can get us up and running quickly with manipulating our database tables. Over time, we can incrementally replace the generated CRUD operations and views with our own-- presumably much prettier and more functional. Page 15

Problems with Scaffolding(1) No data validations. Our User model accepts data such as blank names and invalid email addresses without complaint. No authentication. We have no notion signing in or out, and no way to prevent any user from performing any operation. No tests. This isnt technically true the scaffolding includes rudimentary tests. Page 16

Problems with Scaffolding(2) The scaffolding includes rudimentary tests but the generated tests are ugly and inflexible, and they dont test for data validation, authentication, or any other custom requirements. No layout. There is no consistent site styling or navigation. Page 17

The RoR Architecture Page 18

Components of Ruby on Rails Page 19

Model Classes Based on Martin Fowlers ActiveRecord pattern From Patterns of Enterprise Architecture An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data. Page 20

ActiveRecord No XML files needed. Lots of reflection and run-time extension provided. Magic is not inherently a bad word. We can drop down to SQL for odd cases and performance if needed. Doesnt attempt to duplicate or replace data definitions. Page 21

ActiveRecord API The Following are the features of API Automatic mapping between columns and class attributes. Declarative configuration via macros. Dynamic finders. Associations, Aggregations. Locking. Validation rules Page 22

ActiveRecord Aggregations Aggregation expresses a composed of relationship Define value objects by using composed_of method Tells Rails how value objects are created from the attributes of the entity object when the entity is initialized and How it can be turned back into attributes when the entity is saved to the database Adds a reader and writer method for manipulating a value object Attempting to change value objects result in a TypeError Value objects should be immutable and that requirement is enforced by Active Record by freezing any object assigned as a value object. Page 23

ActionController API Controllers defined as classes that execute and then either render a template or redirects An action is a public method on the controller Getting data in and out of controllers Request parameters available in the @params hash Web session exposed as @session hash Cookies exposed as @cookies hash Redirect scope provided by @flash hash (unique to Rails) Page 24

V-View Rails gives you many rendering options Default template rendering. Explicitly render to particular action. Redirect to another action. Render a string response. Page 25

Viewing Templates ERB Embedded Ruby Similar to JSPs Easy to learn and teach to designers Execute in scope of controller Denoted with.rhtml extension XmlMarkup Programmatic View Construction Great for writing xhtml and xml content Denoted with.rxml extension Embeddable in ERB templates Page 26

Exception Handling Exceptions do arise knowingly or unknowingly where the behavior is different from expected. Exceptions can either be rescued for public view (with a nice user-friendly explanation) for developers view (with tons of debugging information) By default, requests from localhost get developers view Page 27

ActiveSupport API Rails utility methods Number handling Date conversion Time calculations String conversions and inflection Page 28

ActionMailer API Rails built-in email service We can write email controllers in same way as web controllers making it is easy to use. Integrated with templating system for end user friendliness. Page 29

ActionWebService API Web Services is a prime application of RoR. Rails has built-in support for SOAP and XML-RPC Struct base class can be used to represent structured types that dont have ActiveRecord implementations or to avoid exposing an entire model to callers Examples Define a web services client in one line Add a web service to a controller (next slide) Page 30

Defining a WebService Page 31

Security Aspect of RoR Page 32

Sessions and Security(1) Rails provides storage mechanisms for session hashes importantly ActiveRecordStore and CookieStore. CookieStore saves the session hash directly in a cookie on the client-side. The server retrieves the session hash from the cookie and eliminates the need for a session id. CookieStore implimentation makes it a fast application. Session Fixation could be overcome by creating a new session with a single line command using Rails. reset_session Page 33

Sessions and Security(2) Replay attacks could be countered using maintaining certain type of data as a database rather than in sessions. Cross Site Request Forgery (CSRF) could be countered by using GET, POST or a Security Token Implementation. Possible areas to be considered further: Redirection, File Uploads, File Downloads, Executable code usage in Files etc. Page 34

Sessions and Security(3) Mass Assignment- Countered by providing attributes in ActiveRecord for Admin. User Management includes updates and plug-ins. This could be maintained by RoR with the help of restful_authentication feature. Injections: SQL Injection and Cross Site Scripting (XSS). Measures from RoR include built in filter for SQL special characters, Helper methods to fend XSS attacks, etc. There are many other aspects but I have restricted myself only until this point. Page 35

Resources Page 36

The Rails Community The developer community around Rails is very helpful and excited Rails Wiki - http://wiki.rubyonrails.com/ Rails Mailing List very active IRC Get instant answers to most questions. David and other Rails commiters are all regularly present Page 37

References http://sixrevisions.com/web-development/four-ways-ruby-on-rails-can-helpyou/ http://www.smashingmagazine.com/2009/03/19/getting-started-with-rubyon-rails/ http://onlamp.com/pub/a/onlamp/2005/10/13/what_is_rails.html?page=7 http://rubyonrails.org/ http://files.fredbrunel.com/docs/ruby%20on%20rails%20-%20free %20Presentation.pdf http://www.scribd.com/doc/12353866/ruby-on-rails-power-point http://www.tutorialspoint.com/ruby-on-rails/rails-examples.htm www.rubydoc.org/.../introduction%20to%20ruby%20and%20ror %20given%20to%20the%20... Page 38

Thank You Page 39