Pete Helgren pete@valadd.com. Ruby On Rails on i

Similar documents
Ruby On Rails. CSCI 5449 Submitted by: Bhaskar Vaish

Building and Deploying Web Scale Social Networking Applications Using Ruby on Rails and Oracle. Kuassi Mensah Group Product Manager

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

OpenMind: Know Your Customer

Evaluation. Chapter 1: An Overview Of Ruby Rails. Copy. 6) Static Pages Within a Rails Application

Web Development Frameworks

Ruby on Rails in GlassFish Sun Microsystems

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

Ruby on Rails (Ruby 1.9.2, Rails 3.1.1) Installation

The Other mod_rails: Easy Rails Deployment with JRuby. Nick Sieger Sun Microsystems, Inc

Upgrade Guide. Product Version: Publication Date: 02/11/2015

Building Ruby, Rails, LightTPD, and MySQL on Tiger

FileMaker Server 15. Getting Started Guide

How To Run A Hello World On Android (Jdk) On A Microsoft Ds.Io (Windows) Or Android Or Android On A Pc Or Android 4 (

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

GoAnywhere Director to GoAnywhere MFT Upgrade Guide. Version: Publication Date: 07/09/2015

Installing Ruby on Windows XP

SECURE MOBILE ACCESS MODULE USER GUIDE EFT 2013

Introduction. Just So You Know... PCI Can Be Difficult

Integrate Rails into an Existing IIS Web infrastructure using Mongrel

The IBM i on Rails + + Anthony Avison anthony@powerruby.com. Copyright 2014 PowerRuby, Inc.

JRuby Now and Future Charles Oliver Nutter JRuby Guy Sun Microsystems

BEST WEB PROGRAMMING LANGUAGES TO LEARN ON YOUR OWN TIME

Install guide for Websphere 7.0

Installation overview

LDAPCON Sébastien Bahloul

2015, André Melancia (Andy.PT) 1

JobScheduler Installation by Copying

Rapid Application Development. and Application Generation Tools. Walter Knesel

Kony MobileFabric. Sync Windows Installation Manual - WebSphere. On-Premises. Release 6.5. Document Relevance and Accuracy

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

GoAnywhere MFT Upgrade Guide. Version: Publication Date: 08/12/2015

Installing buzztouch Self Hosted

User's Guide - Beta 1 Draft

VERSION 9.02 INSTALLATION GUIDE.

The Learn-Verified Full Stack Web Development Program

Bring your intranet to the IBM i With Drupal and Zend Server

IBM Campaign Version-independent Integration with IBM Engage Version 1 Release 3 April 8, Integration Guide IBM

Using the Eclipse Data Tools Platform with SQL Anywhere 10. A whitepaper from Sybase ianywhere

Tutorial: Mobile Business Object Development. SAP Mobile Platform 2.3 SP02

Migrating Applications From IBM WebSphere to Apache Tomcat

aspwebcalendar FREE / Quick Start Guide 1

About us. Proximity 2015

Unicenter NSM Integration for BMC Remedy. User Guide

Rhomobile cross-platfrom

AJ Matrix V5. Installation Manual

Google App Engine f r o r J av a a v a (G ( AE A / E J / )

PHP on IBM i: What s New with Zend Server 5 for IBM i

32-Bit Workload Automation 5 for Windows on 64-Bit Windows Systems

System i Access for Web Configuring an Integrated Web Application Server Instance

How To Install Amyshelf On Windows 2000 Or Later

SW5706 Application deployment problems

mylittleadmin for MS SQL Server 2005 from a Webhosting Perspective Anthony Wilko President, Infuseweb LLC

FileMaker Server 13. Getting Started Guide

VMware Software Manager - Download Service User's Guide

Personal Token Software Installation Guide

DBX. SQL database extension for Splunk. Siegfried Puchbauer

EVALUATION ONLY. WA2088 WebSphere Application Server 8.5 Administration on Windows. Student Labs. Web Age Solutions Inc.

How to Install MediaWiki on Windows Server 2003

Ricardo Perdigao, Solutions Architect Edsel Garcia, Principal Software Engineer Jean Munro, Senior Systems Engineer Dan Mitchell, Principal Systems

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

WebSphere Business Monitor V7.0: Clustering Single cluster deployment environment pattern

Sametime Gateway Version 9. Deploying DMZ Secure Proxy Server

Force.com Migration Tool Guide

Building Web Applications, Servlets, JSP and JDBC

AdRadionet to IBM Bluemix Connectivity Quickstart User Guide

Magento Search Extension TECHNICAL DOCUMENTATION

1. Was ist das? II. Wie funktioniert das? III. Wo funktioniert das nicht?

by

Getting Started using the SQuirreL SQL Client

Setting up the Oracle Warehouse Builder Project. Topics. Overview. Purpose

Bring your intranet to the IBM i With Drupal and Zend Server

RaidenFTPD Log Analyser Web Edition

IceWarp Server Windows Installation Guide

Adeptia Suite 6.2. Application Services Guide. Release Date October 16, 2014

Installing Rails 2.3 Under Windows XP and Apache 2.2

Guides.rubyonrails.org

Open Source Job Scheduler

To install Multifront you need to have familiarity with Internet Information Services (IIS), Microsoft.NET Framework and SQL Server 2008.

Asia Web Services Ltd. (vpshosting.com.hk)

AWS Schema Conversion Tool. User Guide Version 1.0

FileMaker 12. ODBC and JDBC Guide

Dataworks System Services Guide

NGASI Universal APP Panel Administration and User Guide WebAppShowcase DBA NGASI

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

IBM TRIRIGA Anywhere Version 10 Release 4. Installing a development environment

Tutorial: Android Object API Application Development. SAP Mobile Platform 2.3 SP02

DiskPulse DISK CHANGE MONITOR

MATLAB Distributed Computing Server with HPC Cluster in Microsoft Azure

Livezilla How to Install on Shared Hosting By: Jon Manning

Transcription:

Pete Helgren pete@valadd.com Ruby On Rails on i Value Added Software, Inc 801.581.1154 18027 Cougar Bluff San Antonio, TX 78258 www.valadd.com www.petesworkshop.com (c) copyright 2014 1

Agenda Primer on Ruby Review Prerequisites Install Ruby/JRuby Install Rails Install Activerecord-JDBC (DB Connectivity) Review Rails (quick overview) Build a Blog Application Run all of it Play (a bit) www.valadd.com www.petesworkshop.com (c) copyright 2014 2

What is Ruby? Ruby Primer Object oriented language first released in 1995 that is a scripting language that was more powerful than Perl, and more object-oriented than Python - Yukihiro Matsumoto Find out more at http://www.ruby-lang.org/ What is Rails? Rails is an open source Ruby framework for developing web-based, database-driven applications. Stresses DRY development and convention over configuration (leverage reflection and discovery). www.valadd.com www.petesworkshop.com (c) copyright 2014 3

Ruby relative to other languages 2009 (from langpop.com www.valadd.com www.petesworkshop.com (c) copyright 2014 4

Ruby relative to other languages 2010 (from langpop.com www.valadd.com www.petesworkshop.com (c) copyright 2014 5

Ruby relative to other languages 2011 (from langpop.com www.valadd.com www.petesworkshop.com (c) copyright 2014 6

Ruby relative to other languages 2012 (from langpop.com www.valadd.com www.petesworkshop.com (c) copyright 2014 7

Ruby relative to other languages 2013 from langpop.com www.valadd.com www.petesworkshop.com (c) copyright 2014 8

Sites built with Rails More sites: http://rubyonrails.org/applications www.valadd.com www.petesworkshop.com (c) copyright 2014 9

Why use Ruby/Rails? Reasons are similar to PHP May have skills available (and more readily available) Tons of code and complete applications Many online books and tutorials Can run natively on i (in a couple of different ways) Quick development of web sites www.valadd.com www.petesworkshop.com (c) copyright 2014 10

Possible Gotchas Learning curve Ruby is WAY different from anything you have seen as an RPG programmer. Some installation issues on i (JRuby) J9 JVM and native extensions Native access to IBM i APIs Legacy field naming issues PowerRuby (NEW!) takes care of many of these. www.valadd.com www.petesworkshop.com (c) copyright 2014 11

JRuby Installation on i (easy) Unzip the jruby-bin-1.6.7.2.zip (latest) into the IFS (I put mine in the /usr/local folder) Add the following hack to the jruby script file: # Hacks to make this friendlier to IBM i JRUBY_BASE=/usr/local/jruby-1.6.7.2 JRUBY_HOME=/usr/local/jruby-1.6.7.2 JAVA_HOME=/QOpenSys/QIBM/ProdData/JavaVM/ jdk60/32bit The JAVA_HOME should point to at least Java 1.6 (32 bit is fastest on i) www.valadd.com www.petesworkshop.com (c) copyright 2014 12

Check the install Type QSH to start Qshell (PASE) which is where all of the action takes place with JRuby and Rails. Then type the jruby -v command to check the installed version level We are good to go! www.valadd.com www.petesworkshop.com (c) copyright 2014 13

PowerRuby Install (NEW!) PowerRuby is in beta so you'll have to contact them directly for an install but once done... (just a series of RSTLICPGM from a SAVF) Looks a lot like the JRuby command prompt www.valadd.com www.petesworkshop.com (c) copyright 2014 14

Install Rails Type 'gem install rails' (without the quotes) ri and RDoc are documentation for the gems www.valadd.com www.petesworkshop.com (c) copyright 2014 15

Build the application framework Rails is an application framework. It not only can execute and run the web application but it can also generate the framework needed to build the application. The rails command does it all. What isn't shown above is a long list of other skeletal framework resources that rails will create for the application. Rails will also run the bundler gem to make sure all gems required by the application are installed. www.valadd.com www.petesworkshop.com (c) copyright 2014 16

Install Rails dependencies Bundler is a gem tool that installs dependencies for Ruby applications. Gems are applications and libraries that have helper programs for Ruby applications. The rails 'new' command will create the skeletal framework and run bundler which should give you all you need but occasionally you may add other features that require additional gems so running 'bundle install' will take care of the details for you. www.valadd.com www.petesworkshop.com (c) copyright 2014 17

Verify installation When bundler completes, you should see that last line indicating that rails is ready to go. www.valadd.com www.petesworkshop.com (c) copyright 2014 18

Start the web application Change your directory to the application folder (created by rails new) and then start the rails application. Rails has a minimalist web server called WEBrick that is great for testing apps but generally shouldn't be used in production. The start command is 'rails s' but I added the -p switch to start the server on a different port (3080 in this case) www.valadd.com www.petesworkshop.com (c) copyright 2014 19

Security You may receive a security warning when you start your rails app. For testing this is OK because you will probably only run the rails app locally. You need to fix this before you go into production. Just follow the instructions on the warning (Google will help) www.valadd.com www.petesworkshop.com (c) copyright 2014 20

Display the welcome page It's difficult to see in this screen shot but the app is running on my IBM i (10.0.10.205 on my internal network) at port 3080. www.valadd.com www.petesworkshop.com (c) copyright 2014 21

Check on the environment www.valadd.com www.petesworkshop.com (c) copyright 2014 22

Adding to the framework Probably will want a new welcome page so lets start with something simple: A new index page: rails generate controller home index After the resources have been generated, delete the index.html.erb file in the public folder Hack the index.html.erb file in the app/views/home folder to have the following: <h1>hello, Rails on IBM I! </h1> www.valadd.com www.petesworkshop.com (c) copyright 2014 23

Adding to the framework Add the following to the routes.rb (in the config folder) file by uncommenting the line: #... # You can have the root of your site routed with "root" # just remember to delete public/index.html. root :to => "home#index" This sets your home page to the index.html.erb file in the home folder. www.valadd.com www.petesworkshop.com (c) copyright 2014 24

Adding to the framework (building the blog application) Generate a resource using the rails 'generate' command (rails g for short). The generate command creates all of the framework for the resource. rails g scaffold post title:string body:text www.valadd.com www.petesworkshop.com (c) copyright 2014 25

Building on the framework The 'generate scaffold' command gave us the following resources in our project: Migration Model Controller Helper We'll be working with these resources to create our blog application. www.valadd.com www.petesworkshop.com (c) copyright 2014 26

Migrations Rails works with many databases sqlite is used by default. Since we are using JRuby, we will need to make sure that the activerecord-jdbc-adapter gem is installed. This allows us to use any database resources that has a JDBC driver available. This is the best solution for using DB2 and MySQL on IBM i. You will need to make a change to the database.yml file. www.valadd.com www.petesworkshop.com (c) copyright 2014 27

Migrations (cont) Migrations allow us to track database changes from the very beginning of application development. We can then roll back or roll forward to/from any database schema modifications we have made Very cool! www.valadd.com www.petesworkshop.com (c) copyright 2014 28

Editing files Ruby files are just text files you can edit with any text editor. I use an IDE called RubyMine. There are many others. www.valadd.com www.petesworkshop.com (c) copyright 2014 29

database.yml hack www.valadd.com www.petesworkshop.com (c) copyright 2014 30

Run the migration From here on out whenever I make a change to the schema; Adding a table, changing the columns of any table I run migrate and it will back up and change the schema and track those schema changes www.valadd.com www.petesworkshop.com (c) copyright 2014 31

A couple of additional changes The original application 'index' in the public folder and the application index in the layout folder (views) need to be deleted www.valadd.com www.petesworkshop.com (c) copyright 2014 32

Restart the Application (new scaffold in place) The scaffold basically builds a CRUD application based on the resource template. This can be as complex or as simple as you want but for a quick and dirty app, you can get pretty far in a short amount of time www.valadd.com www.petesworkshop.com (c) copyright 2014 33

Write some code Start your rails app and leave it running. We'll edit the files directly and rails will update them in real time (its a scripting language, remember!). www.valadd.com www.petesworkshop.com (c) copyright 2014 34

Standard Rails Components Convention over configuration! These are the standard Rails web methods: index list of posts new show the new posts create create a new post entry show show an existing post edit show an existing post for editing update change an existing post destroy delete and existing post www.valadd.com www.petesworkshop.com (c) copyright 2014 35

The magic Scaffold! You don't have to use the full scaffold on a Rails application. You can generate just sections like controllers or models if you want. A quick demo... www.valadd.com www.petesworkshop.com (c) copyright 2014 36

Controller Much of the heavy lifting occurs here: index show new edit create update destroy Let's check out some code... www.valadd.com www.petesworkshop.com (c) copyright 2014 37

Views Most of this is HTML mixed with Ruby (as little as possible. Very similar to PHP and JSP's. Partials are a great way to leverage DRY development by assigning sections of repetitive views to a file. www.valadd.com www.petesworkshop.com (c) copyright 2014 38

Adding links to pages Lets add a link to our posts in the blog by adding this line to our home page: <%= link_to "My IBM i Blog", posts_path %> www.valadd.com www.petesworkshop.com (c) copyright 2014 39

Thanks! Questions? Pete Helgren Value Added Software, Inc. pete@valadd.com http://www.roroni.com/ www.valadd.com www.petesworkshop.com (c) copyright 2014 40