Melbourne LUG Presentation Learning Rails and Ruby - making webapps easier.

Slides:



Advertisements
Similar presentations
Creating Web Services with Ruby on Rails Robert Thew Internet and Web Systems II.
Advertisements

1 JRuby on Rails GAO ANG Sun Functional Campus Ambassador 1.
Creating Web Services with Ruby on Rails Robert Thew Internet and Web Systems II.
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.
Creating a wiki blog. Run apps that come with instant rails distribution select I /rails applications/open ruby console window Cd to cookbook or typo.
UWWD In our quest to eliminate bad websites, we present…. HALLELUJAH!!
PHP Scripting Language. Introduction “PHP” is an acronym for “PHP: Hypertext Preprocessor.” It is an interpreted, server-side scripting language. Originally.
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.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
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.
Rails and Grails. To get started Make sure you have java installed You can get the sdk and jre at:
1 Dr Alexiei Dingli Web Science Stream Models, Views and Controllers.
UC Berkeley Hello Rails. Review: MVC Goal: separate organization of data (model) from UI & presentation (view) by introducing controller –mediates user.
Background The Encyclopedio of Life (EOL) is an ROR open source project to create a free, online reference source and database for every one of the 1.8.
Data File Access API : Under the Hood Simon Horwith CTO Etrilogy Ltd.
1 Dr Alexiei Dingli Web Science Stream Advanced ROR.
Bonrix SMPP Client. Index Introduction Software and Hardware Requirements Architecture Set Up Installation HTTP API Features Screen-shots.
Putting Applets into Web Pages.  Two things are involved in the process of putting applets onto web pages ◦ The.class files of the applet ◦ The html.
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.
Lecture 11 Rails Topics SaaSSaaS Readings: SaaS book Ch February CSCE 740 Software Engineering.
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.
Associations INFO 2310: Topics in Web Design and Programming.
Ruby on Rails WTF? Created by Matz in 1993 Inspired by Smalltalk Rubygems = CSPAN Rake = ant Rdoc = javadoc.
Photo Gallery INFO 2310: Topics in Web Design and Programming.
BIT 286: Web Applications Automated Web Testing. Selenium  Selenium Is moving from being Firefox based to being more of a 'normal desktop' program that.
1 Dr Alexiei Dingli Web Science Stream Web We’ll implement a voting mechanism Using AJAX Web 2.0.
Ruby on Rails on Ubuntu Bradley Taylor Rails Machine, LLC
RUBY ON RAILS (RoR) Ishwor Khadka. Why Ruby on Rails?
Chapter 15 © 2013 by Pearson Overview of Rails - Rails is a development framework for Web-based applications - Based on MVC architecture for applications.
Checking under the Hood: A Guide to Rails Engines Mike Perham
Studio Fx on Rails Demonstrating the Studio Fx API.
Introduction to Ruby&Rails Yuri Veremeyenko Monica Verma.
1 Dr Alexiei Dingli Web Science Stream Installing ROR.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
Introduction to information systems RUBY ON RAILS dr inż. Tomasz Pieciukiewicz.
Migrations Carol Wolf CS 396X. ISBNTitleAuthorImage EmmaAustenemma.jpg Oliver TwistDickenstwist.jpg HamletShakespearehamlet.jpg.
Introduction to Linux Server Setup Jonathan Hood CSE 4000 Practical Issues in Software Engineering.
HTML Review * is used as a reference for most of the notes in this powerpoint.
1 Rails for the Ruby-Impaired John Paul Ashenfelter CTO/Transitionpoint.
Advanced Migration By Aye Mon Tun.  To change database schema in consistent and easy way  In ruby code Migration? 11/25/2013 2Web Application Engineering.
Your current Moodle 1.9 Minimum Requirements Ability to do a TEST RUN! Upgrading Moodle to Version 2 By Ramzan Jabbar Doncaster College for the Deaf By.
 Project Team: Suzana Vaserman David Fleish Moran Zafir Tzvika Stein  Academic adviser: Dr. Mayer Goldberg  Technical adviser: Mr. Guy Wiener.
Joomla Awdhesh Kumar Singsys Pte Ltd. What is Joomla? Joomla is an award-winning content management system (CMS), which enables you to build Web sites.
Presented By P.SRIVIDYA 085D1A0552 Programming Language.
JRuby on Rails Presenter Name
XNAT 1.7: Getting Started 6 June, Introduction In this presentation we’ll discuss:  Features and functions in XNAT 1.7  Requirements  Installing.
JRuby on Rails Brian Leonard ブライアン レオナルド
Mid-Hudson Valley Linux Users Group Ruby on Rails Web Development is Fun Again MHVLUG Meeting Jan 7 th 2009 Sean Dague sean.dague.net.
The Holmes Platform and Applications
Development Environment
BEHAVIOR DRIVEN DEVELOPMENT / TESTING (BDD)
Ruby Tooling in NetBeans
PHP / MySQL Introduction
Top 5 Front End Development Tools. 1. Sublime Text Sublime Text may be a super quick and have packed text and development editor. If you're about to be.
INSTALLING AND SETTING UP APACHE2 IN A LINUX ENVIRONMENT
Agile Web Development with Ruby and Rails
Chapter 15 Introduction to Rails.
Cordova & Cordova Plugin Installation and Management
Designing and Using Normalization Rules
Download from Zotero Home Page
Introduction to Web Application Design
Introduction to Web Application Design
Review of Previous Lesson
Web Application Development Using PHP
Presentation transcript:

Melbourne LUG Presentation Learning Rails and Ruby - making webapps easier

Ruby...what is ruby? ● Its a: – dynamiclly-typed – garbage collecting – line-oriented – object-oriented – reflection-capable language ● Its derived from Perl and LISP ● Its ten years old

Do you do that in English? ● You write less code, a lot less code ● There isn't much boilerplate (e.g. ;) ● You can write large applications ● You can write natural DSLs ● Sadly though, its very, very slow

Now what about this Rails thing? ● Its a web framework ● Has a strong MVC focus ● Comes with AJAX, REST ad WS goodness ● Has a strong convention over configuration preference ● Used by the big boys: – BBC – LinkedIn – Twitter

I'm not convinced

What do you need? ● Any recent Linux, Mac, Solaris or even Windows machine – NB: Windows performance is awful ● A good text editor ● A web application idea :)

There are a couple of ways to get started... ● Instant rails – a package that gives you apache, rails, ruby and mysql – however windows only ● Distro packages – Ubuntu has ruby packages you can install, just add rails via gems – gems via apt locks you at old versions – see

Compiling Ruby ● You'll need some tools to get started: – apt-get install ● build-essentials, zlib1gb, zlib1gb-dev – Get the latest ruby from –./configure && make && sudo make install ● After that get rubygems from: – get rubygems (v1.0.1 or above) from rubyforge.org – sudo ruby setup.rb install

When do we get to make webapps?

Not yet, I just want to take a little detour ● gems – The ruby packaging system – Awesome versioning so you can peg to a version or mandate a minimum or maximum version – Basic dependancy checking – Use is simple via the gem command – Then simply use for your own nefarious purposes.

Detour continued... ● gems commands you need to know: – gem install - install a gem (may need sudo) – gem server – start documentation daemon – gem list --remote – find out what gems and versions are on the gem servers – gem query - search for a gem – gem update – update gems – gem uninstall - remove a gem

I'm turning to stone here!!!

OK OK here we go rails tickets – creates a rails project called tickets cd tickets && ruby script/server ● now you get a running app in a browser! ● erm...it doesn't do much though :( ● NB from here all paths are relative to tickets

Now let's hook to a database ● All databases live in config/database.yml ● there are three default databases, development, testing and production ● configuration is done via YAML ● edit the details to suit your database (postgresql) ● then run rake db:migratedb:migrate ● your database should now have a table called schema_info (this is important do not touch!)

Another detour...rake ● rake is the ruby equivalent of make ● it has dependancies and namespaces ● it has a cool DSL for tasks ● its all ruby so you can write ruby to extend it :) ● rake files are called Rakefile by default ● rake -T will tell you all the tasks a rakefile can execute ● We'll talk more about this later...

Now lets generate a data model ● Rails uses migrations to build its data model ● migrations are found in db/migrate ● migrations are numbered from 001 ● use the generation script: – ruby script/generate migration ● then edit the file... ● This gives you a great piecemeal development approach.

A migration file class CreateTicket < ActiveRecord::Migration def self.up create_table :tickets do |t| t.string :title t.text :description t.integer :severity end def self.down drop_table :tickets end

Now let's generate some more ● run the following: script/generate scaffold Ticket title:string description:text severity:integer ● now hit your web browser ● hey, I can make tickets!

Spot the changes in the database ● select * from schema_info; ● run rake db:migratedb:migrate ● whoa...new table called tickets ● select * from schema_info; ● see the number? ● but nothing uses it, yet

Create users ● OK now we'll do the same but for users: ● generate the migration and support files at once: script/generate scaffold User name:string active:boolean

Now we need to link them up ● We know there is a relationship between users and tickets. ● So lets implement it: ● Open your user model (app/models/user.rb) and inside the class definition put the following: has_many :tickets ● Then generate a migration script/generate migration link_to_users

Plugins ● Plugins are extensions to rails. ● This keeps rails small and light. ● Installation can be achieved by script/plugin install ● The software sits in the vendor/plugins directory. ● To install ActiveScaffold for AJAX scaffolds do: script/plugin install

Now lets use ActiveScaffold ● Open app/views/layouts/users.html.erb ● Add the following inside the head tag: Then rip out the action code and add the following to app/controllers/users_controller.rb acive_scaffold :user

So simple even a politician could do it...

validation ● Rails comes with a set of validations pre- cooked. ● This makes for very expressive logic. For instance... ● Lets stop people making terse tickets ● Open app/models/ticket.rb and enter: validates_presence_of :description ● Now whenever you save a ticket Rails checks whether description is blank.

Test Driven Development/TDD ● TDD is the basic rails testing and its good. ● You write a test and then run: rake test ● Which runs all of your tests. ● We're only checking a model here so we run rake test:models ● next we open test/unit/ticket_test.rb

Testing a validation def test_blank_description test_ticket = Ticket.new test_ticket.title = "first test" test_ticket.save assert test_ticket.valid? end

What next? ● It fails! ● But that's OK... ● change the assert line to: assert_equal test_ticket.valid?, false ● Now the test passes and we know the validation works.

Some Of What We Haven't Talked About... ● Views ● Javascript, AJAX and bling ● Helpers ● BDD and rspec ● Mongrel ● HAML

Where to find out more? ● Check out: ● Books: – Ruby and Rails – David Black – The Pickaxe book ● Websites – – ● Melbourne Ruby Group (just google us).

Thanks to ● Flickr folk: – Libertinus – Annerna – Demona ● Development lords: – Matz & the Ruby maintainers – DHH & the Rails folk.