Lecture 11 Rails Topics SaaSSaaS Readings: SaaS book Ch 4.1-4.5 February 24 2014 CSCE 740 Software Engineering.

Slides:



Advertisements
Similar presentations
Ruby on Rails Model of MVC. Model-View-Controller Paradigm A way of organizing a software system Benefits: Isolation of business logic from the user interface.
Advertisements

Chapter 15 © 2010 by Addison Wesley Longman, Inc Origins and Uses of Ruby - Designed by Yukihiro Matsumoto; released in Use spread rapidly.
Creating Web Services with Ruby on Rails Robert Thew Internet and Web Systems II.
Introduction to Model-View-Controller (MVC) Web Programming with TurboGears Leif Oppermann,
Ruby on Rails by Manik Juneja Ruby On Rails. Ruby on Rails by Manik Juneja Rails is a Web Application development framework. Based on the MVC pattern.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
CS 290C: Formal Models for Web Software Lecture 10: Language Based Modeling and Analysis of Navigation Errors Instructor: Tevfik Bultan.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 11: Monitoring Server Performance.
27-Jun-15 Rails. What is Rails? Rails is a framework for building web applications This involves: Getting information from the user (client), using HTML.
Software Architecture Patterns (2). what is architecture? (recap) o an overall blueprint/model describing the structures and properties of a "system"
Tomcat Configuration A Very, Very, Very Brief Overview.
Ruby on Rails CSE 190M, Spring 2009 Week 5. Installing Rails First, install Ruby with RubyGems Then, install the Rails gem gem install rails -version=2.3.2.
Ruby on Rails Creating a Rails Application Carol E Wolf CS396X.
Ruby on Rails (Slides modified by ements-2ed.shtml)
FileSecure Implementation Training Patch Management Version 1.1.
Linux Operations and Administration
Ruby on Rails: An Introduction JA-SIG Summer Conference 2007 Michael Irion The University of Tulsa.
RUBY ON RAILS Mark Zhang. In this talk  Overview of Ruby on Rails  Core ideas  Show a tiny bit of example code  Touch on several general web development/
Ruby on Rails. What is Ruby on Rails? Ruby on Rails is an open source full-stack web framework. It is an alternative to PHP/MySQL. It can render templates,
Ruby on Rails CSCI 6314 David Gaspar Jennifer Garcia Avila.
ZFApp Preview Walkthrough. What is ZFApp? ZFApp is an application framework built on top of Zend Framework Fully compatible with the latest ZF Versions.
Rails and Grails. To get started Make sure you have java installed You can get the sdk and jre at:
UC Berkeley Hello Rails. Review: MVC Goal: separate organization of data (model) from UI & presentation (view) by introducing controller –mediates user.
Chapter 4.1 – Deeper into Rails Maciej Mensfeld Presented by: Maciej Mensfeld Deeper into Rails mensfeld.pl github.com/mensfeld senior.
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
1 Chapter 2 & Chapter 4 §Browsers. 2 Terms §Software §Program §Application.
Model-View-Controller
Designing For Testability. Incorporate design features that facilitate testing Include features to: –Support test automation at all levels (unit, integration,
Basic Programming in Ruby Today’s Topics: Introduction last class irb history log Methods Classes (briefly) Using 3 rd Party Libraries rubygems ‘ require.
Lecture 8 Software as a Service (SaaS )
MVC & ActiveRecord by Christian Mohr & Mohamed Souiai.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Lecture 19 Web Application Frameworks Boriana Koleva Room: C54
1 Apache. 2 Module - Apache ♦ Overview This module focuses on configuring and customizing Apache web server. Apache is a commonly used Hypertext Transfer.
Lecture 10 Rails Projects Topics SaaSSaaS Readings: SaaS book Ch 2, 4 February 24, 2014 CSCE 740 Software Engineering.
1 Dr Alexiei Dingli Web Science Stream Introducing Rails.
Introduction to Model-Glue Rachel Lehman Perpetual Intermediate Designer-Developer Introduction to Model-Glue.
Ruby on Rails Your first app. Rails files app/ Contains the controllers, models, views and assets for your application. You’ll focus on this folder for.
Introduction to Entity Framework Part 2 CRUD Scaffolding Tom Perkins NTPCUG.
Ruby on Rails CSE 190M, Spring 2009 Week 6. Overview How to use a database Demo creating a blog application on Rails Explain how the application works.
The Active Record Paradigm Databases in Database-Centric Web Site Development.
Oracle Data Integrator Procedures, Advanced Workflows.
Ruby on Rails (Slides modified by ements-2ed.shtml)
ASP.NET The Clock Project. The ASP.NET Clock Project The ASP.NET Clock Project is the topic of Chapter 23. By completing the clock project, you will learn.
Ruby on Rails: Databases. Rails Database Familiar Table Concept Naming convention – lower case, plural (i.e. tweets) How to Access (find), Update, Delete.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment, Enhanced Chapter 11: Monitoring Server Performance.
Selenium and Selenium on Rails. Agenda  Overview of Selenium Simple Selenium Tests Selenium IDE  Overview of Selenium on Rails  Problems with Selenium.
What's New in Kinetic Calendar 2.0 Jack Boespflug Kinetic Data.
Chapter 15 © 2013 by Pearson Overview of Rails - Rails is a development framework for Web-based applications - Based on MVC architecture for applications.
Philip Repsher October 29 th, 2008 Or Maybe November 3 rd, 2008.
Lecture 13b Rails – Controllers and Views Topics SaaSSaaS Readings: SaaS book Ch March 3, 2014 CSCE 740 Software Engineering.
Ruby on Rails Controller of MVC. Routes How we map URIs like /tweets/1 to calling the show method of the Controller.
Rails and routing INFO 2310: Topics in Web Design and Programming.
SPI NIGHTLIES Alex Hodgkins. SPI nightlies  Build and test various software projects each night  Provide a nightlies summary page that displays all.
CS 160 and CMPE/SE 131 Software Engineering February 9 Class Meeting Department of Computer Science Department of Computer Engineering San José State University.
Ruby on Rails. Web Framework for Ruby Designed to make it easier to develop, deploy, and maintain web applications Design with Model-View-Controller –almost.
1 Rails for the Ruby-Impaired John Paul Ashenfelter CTO/Transitionpoint.
© 2010 IBM Corporation RESTFul Service Modelling in Rational Software Architect April, 2011.
1 Adding a Model. We have created an MVC web app project Added a controller class. Added a view class. Next we will add some classes for managing movies.
Lecture 12 Rails 169 Review Slides Topics SaaSSaaS Readings: SaaS book Ch February CSCE 740 Software Engineering.
Running a Forms Developer Application
Play Framework: Introduction
Play Framework: Introduction
CMPE 280 Web UI Design and Development October 24 Class Meeting
…and web frameworks in general
Ruby on Rails by Manik Juneja
WEB API.
Ruby on Rails by Manik Juneja
…and web frameworks in general
Presentation transcript:

Lecture 11 Rails Topics SaaSSaaS Readings: SaaS book Ch February CSCE 740 Software Engineering

– 2 – CSCE 740 Spring 2014 Tools - Last Time  Ruby Basics  Ruby Regexp New Test 1 Revisit Chapter 2  Classes  Objects Rails  xxx Next Time:

– 3 – CSCE 740 Spring github.com:saasbook/courseware

– 4 – CSCE 740 Spring 2014  Rails exposes the client-server, three-tier architecture, and model–view–controller patterns, all of which are common in SaaS apps.  Rails’ ActiveRecord package uses Ruby’s metaprogramming and convention over configuration to free you from writing any code at all to perform the basic Create, Read, Update and Delete (CRUD) operations on your models, as long as you follow certain conventions about naming classes and variables. Engineering Software as a Service, Patterson & Fox

– 5 – CSCE 740 Spring 2014  Rails’ ActionView and ActionController packages provide help for creating Web pages, dealing with fill- in forms, and setting up the routes that map URIs to controller actions (code in your app).  A properly-constructed Rails app can be easily adapted to work in a service-oriented architecture, communicating with external services rather than with a human using a browser.  Debugging SaaS requires understanding the different places something could go wrong during the flow of a SaaS request, and making that information visible to the developer. Engineering Software as a Service, Patterson & Fox

– 6 – CSCE 740 Spring Rails Basics: From Zero to CRUD Rails is a SaaS application framework that defines a particular structure for organizing your application’s code and provides an interface to a Rails application server such as Rack. The app server waits for a Web browser to contact your app and maps every incoming request (URI and HTTP method) to a particular action in one of your app’s controllers. Three main modules make up the heart of Rails’ support for MVC:  ActiveRecord for creating models,  ActionView for creating views, and  ActionController for creating controllers. Engineering Software as a Service, Patterson & Fox

– 7 – CSCE 740 Spring 2014 Basic Rails application with a single model 1.Creating the skeleton of a new app 2.Routing 3.The database and migrations 4.Models and Active Record 5.Controllers, views, forms, and CRUD Engineering Software as a Service, Patterson & Fox

– 8 – CSCE 740 Spring 2014 Rails command apt-get install rails or aptitude install rails to install rails –help rails –version rails new myrottenpotatoes -T Engineering Software as a Service, Patterson & Fox

– 9 – CSCE 740 Spring 2014 Ruby libraries are called Rubygems Rubygems is a system for managing external user- contributed Ruby libraries or gems. Bundler, a gem, looks for a Gemfile in the app’s root directory that specifies not only what gems your app depends on, but what versions of those gems rails is itself a gem Engineering Software as a Service, Patterson & Fox

– 10 – CSCE 740 Spring 2014 Configuring your Gemfile # use Haml for templates gem 'haml' # use Ruby debugger group :development, :test do gem 'debugger' gem 'debugger'endThen bundle install --without production, Engineering Software as a Service, Patterson & Fox

– 11 – CSCE 740 Spring 2014 automation for repeatability automation for repeatability:  rather than manually installing the gems your app needs,  listing them in the Gemfile and letting Bundler install them automatically ensures that the task can be repeated consistently in a variety of environments, Engineering Software as a Service, Patterson & Fox

– 12 – CSCE 740 Spring 2014 RESTful routes routes – specify the mapping from HTTP method to controller action  rake routes – prints the routes RESTful routes specify self-contained requests of what operation to perform and what entity, or resource, to perform it on Rails shortcut that creates RESTful routes for the four basic CRUD actions (Create, Read, Update, Delete) on a model  g-urls-to-code Engineering Software as a Service, Patterson & Fox

– 13 – CSCE 740 Spring 2014 log/development.log log/development.log is where you look to find detailed error information when something goes wrong. Engineering Software as a Service, Patterson & Fox

– 14 – CSCE 740 Spring 2014 Edit config/routes.rb, replace with Myrottenpotatoes::Application.routes.draw do resources :movies resources :movies root :to => redirect('/movies') root :to => redirect('/movies')end run rake routes again Engineering Software as a Service, Patterson & Fox

– 15 – CSCE 740 Spring 2014 Using convention over configuration  Rails will expect this controller’s actions to be defined in the class MoviesController,  if that class isn’t defined at application start time, Rails will try to load it from the file app/controllers/movies_controller.rb.  Sure enough, if you now reload the page in your browser, you should see a different error: uninitialized constant MoviesController. Engineering Software as a Service, Patterson & Fox

– 16 – CSCE 740 Spring 2014 The root route ’/’, RottenPotatoes’ “home page,” will take us to the main Movie listings page by a mechanism we’ll soon see called an HTTP redirect. Engineering Software as a Service, Patterson & Fox

– 17 – CSCE 740 Spring 2014 Summary:  commands to set up a new Rails app:  rails new sets up the new app; the rails command also has subcommands to run the app locally with WEBrick (rails server) and other management tasks.  Rails and the other gems your app depends on (we added the Haml templating system and the Ruby debugger) are listed in the app’s Gemfile, which  Bundler uses to automate the process of creating a consistent environment for your app whether in development or production mode.  To add routes in config/routes.rb, the one-line resources method provided by the Rails routing system allowed us to set up a group of related routes for CRUD actions on a RESTful resource.  The log files in the log directory collect error information when something goes wrong. Engineering Software as a Service, Patterson & Fox

– 18 – CSCE 740 Spring 2014 ELABORATION: Automatically reloading the app After changing routes.rb, you don’t have to stop and restart the app in order for the changes to take effect. In development mode, Rails reloads all of the app’s classes on every new request, so that your changes take effect immediately. In production this would cause serious performance problems, so Rails provides ways to change various app behaviors between development and production mode, Engineering Software as a Service, Patterson & Fox

– 19 – CSCE 740 Spring 2014 Non-resource based routes Route: get ’:controller/:action/:id’ or get ’photos/preview/:id’ Example URI: /photos/preview/3 Behavior: call PhotosController#preview params[]: {:id=>3} Route: get ’photos/preview/ :id’ Example URI: /photos/look/3?color=true Behavior: no route will match (look doesn’t match preview) Engineering Software as a Service, Patterson & Fox

– 20 – CSCE 740 Spring 2014 Route: get ’photos/:action/:id’ Example URI: /photos/look/3?color=true Behavior: call PhotosController#look (look matches :action) params[]: {:id=>3, :color=>’true’} Route: get ’:controller/:action/:vol/:num’ Example URI: /magazines/buy/3/5?newuser=true&discount=2 Behavior: call MagazinesController#buy params[]: {:vol=>3, :num=>5, :newuser=>’true’, :discount=>’2’. Engineering Software as a Service, Patterson & Fox

– 21 – CSCE 740 Spring 2014 Rails Routing from the Outside In This guide covers the user-facing features of Rails routing. After reading this guide, you will know:  How to interpret the code in routes.rb.  How to construct your own routes, using either the preferred resourceful style or the match method.  What parameters to expect an action to receive  How to automatically create paths and URLs using route helpers.  Advanced techniques such as constraints and Rack endpoints.…

– 22 – CSCE 740 Spring 2014 Databases and Migrations persistence tier uses relational DBMS sqlite3 for development (note WEBrick is webserver-lite) Each environment has its own separate DB  specified in config/database.yml  testing DB only for automated tests (hands off) The production environment should  be a higher performance DB (postgress)  mirror changes to the development DB Engineering Software as a Service, Patterson & Fox

– 23 – CSCE 740 Spring 2014 Migrations So how do we update the production DB in same way as the development DB? Remember DRY? A migration is a portable script for changing the DB schema in a consistent and repeatable way Engineering Software as a Service, Patterson & Fox

– 24 – CSCE 740 Spring 2014 Migration a 3-Step Process 1.Create a migration describing what changes to make. As with rails new, Rails provides a migration generator that gives you the boilerplate code, plus various helper methods to describe the migration. 2.Apply the migration to the development database. Rails defines a rake task for this. 3.Assuming the migration succeeded, update the test database’s schema by running rake db:test:prepare. 4.Run your tests, and if all is well, apply the migration to the production database and deploy the new code to production.  The process for applying migrations in production depends on the deployment environment; Engineering Software as a Service, Patterson & Fox

– 25 – CSCE 740 Spring 2014 Migration Management db/migrate name = time-created + user-supplied-name meaningful to both you and rails Engineering Software as a Service, Patterson & Fox

– 26 – CSCE 740 Spring 2014 Engineering Software as a Service, Patterson & Fox

– 27 – CSCE 740 Spring 2014 Engineering Software as a Service, Patterson & Fox

– 28 – CSCE 740 Spring 2014 Engineering Software as a Service, Patterson & Fox

– 29 – CSCE 740 Spring 2014 Engineering Software as a Service, Patterson & Fox

– 30 – CSCE 740 Spring 2014 Engineering Software as a Service, Patterson & Fox

– 31 – CSCE 740 Spring 2014 Engineering Software as a Service, Patterson & Fox