Trestle Generator Industrial-strength scaffolding for Ruby on Rails web application development.

Slides:



Advertisements
Similar presentations
HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Helena Baert Part II: Let’s get practical! The Web as a notebook This slideshow will help you build a wiki. Don’t worry if you.
The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
July 2010 D2.1 Upgrading strategy Javier Soto Catalog Release 3. Communities.
Creating Web Services with Ruby on Rails Robert Thew Internet and Web Systems II.
Creating rails app. p:\InstantRails\rails_apps>rails -d mysql cars create create app/controllers create app/helpers create app/models create app/views/layouts.
Microsoft Office 2007: Introductory Computer Applications 11.
Newsletter Plugin The newsletter plugin allows you to create and send newsletters to a managed list or multiple lists of users. Your users can subscribe.
Links and Comments.
CS 142 Lecture Notes: Rails ActiveRecordSlide 1 Model for Student Table SELECT * FROM students; | id | name.
Methods for Rails. File Structures This is taken directly from app Holds all the code that's specific.
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.
Browser and Basics Tutorial 1. Learn about Web browser software and Web pages The Web is a collection of files that reside on computers, called.
Ruby on Rails Creating a Rails Application Carol E Wolf CS396X.
Intro to Rails INFO 2310: Topics in Web Design and Programming.
Automation using Selenium Authored & Presented by : Chinmay Sathe & Amit Prabhu Cybage Software Pvt. Ltd.
Creating a Web Page HTML, FrontPage, Word, Composer.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
Ruby on Rails: An Introduction JA-SIG Summer Conference 2007 Michael Irion The University of Tulsa.
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.
Server-side Scripting Powering the webs favourite services.
Creating Effective School and PTA Websites Sam Farnsworth Utah PTA Technology Specialist
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
Ajax and Ruby on Rails Session 9 INFM 603.
1 Dr Alexiei Dingli Web Science Stream Helpers, Forms and Layouts.
1 Dr Alexiei Dingli Web Science Stream Advanced ROR.
Adobe Certified Associate Objectives 6 Evaluating and Maintaining a site.
Blogging Transforming Writing for the 21 st Century.
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.
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.
1 Dr Alexiei Dingli Web Science Stream A ROR Blog.
Chapter 15 © 2009 by Addison Wesley Longman, Inc Overview of Rails - Rails is a development framework for Web-based applications - Rails is written.
Photo Gallery INFO 2310: Topics in Web Design and Programming.
CS 142 Lecture Notes: Rails ActiveRecordSlide 1 Model for Student Table SELECT * FROM students; | id | name.
1 Dr Alexiei Dingli Web Science Stream A ROR Twitter.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
Selenium and Selenium on Rails. Agenda  Overview of Selenium Simple Selenium Tests Selenium IDE  Overview of Selenium on Rails  Problems with Selenium.
1 Dr Alexiei Dingli Web Science Stream Web We’ll implement a voting mechanism Using AJAX Web 2.0.
Exchange 2013 Web App (OWA) User Guide. Table of Contents How to Logon Opening View Navigation Mail Contacts Calendar 2.
Chapter 15 © 2013 by Pearson Overview of Rails - Rails is a development framework for Web-based applications - Based on MVC architecture for applications.
Create, Update and Delete Carol Wolf Computer Science.
Studio Fx on Rails Demonstrating the Studio Fx API.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
Introduction to Ruby&Rails Yuri Veremeyenko Monica Verma.
HTML Links HTML uses a hyperlink to another document on the Web.
Web Authoring with Dreamweaver. Unit Objectives  Be able to define keywords: HTML, HTTP (protocol), browser, web server, client/server, tag, attribute,
1 Dr Alexiei Dingli Web Science Stream Installing ROR.
Rails and routing INFO 2310: Topics in Web Design and Programming.
AJAX in Ruby-on-Rails. Ruby on Rails and AJAX AJAX can be done with just Javascript Easier if you use libraries –Prototype –SAJAX –jQuery Libraries only.
CS 160 and CMPE/SE 131 Software Engineering February 9 Class Meeting Department of Computer Science Department of Computer Engineering San José State University.
Migrations Carol Wolf CS 396X. ISBNTitleAuthorImage EmmaAustenemma.jpg Oliver TwistDickenstwist.jpg HamletShakespearehamlet.jpg.
CS 160 and CMPE/SE 131 Software Engineering February 11 Class Meeting Department of Computer Science Department of Computer Engineering San José State.
Wikis in Education: Part III Wiki Basics University School of Milwaukee.
Creating Web Pages with Links, Images, and Embedded Style Sheets
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
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.
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.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC -
Melbourne LUG Presentation Learning Rails and Ruby - making webapps easier.
 Open the course to add an online class  Click on Add a Page (left side)  Type in a name  Click on Create  Click on the Content Tab  Click on Add.
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.
1 After completing this lesson, you will be able to: Create and edit hyperlinks in worksheets. Save worksheets and workbooks as Web pages. Send workbooks.
JavaScript and Ajax (Ajax Tutorial)
Tutorial 7 – Integrating Access With the Web and With Other Programs
MVC Controllers.
Presentation transcript:

Trestle Generator Industrial-strength scaffolding for Ruby on Rails web application development

What is Rails scaffolding? One of the “wows” of early RoR demos One of the “wows” of early RoR demos Minimal generated code for access to a database table Minimal generated code for access to a database table A starting point for applications—you’ll augment and rework scaffolds into a full- fledged application A starting point for applications—you’ll augment and rework scaffolds into a full- fledged application

What does scaffolding give you? A model (if it doesn’t already exist) A model (if it doesn’t already exist) A controller with actions index, list, new, create, show, edit, update, and destroy A controller with actions index, list, new, create, show, edit, update, and destroy Four view templates: list, new, show, and edit Four view templates: list, new, show, and edit A view layout A view layout A stylesheet A stylesheet A helper class A helper class A unit test case (if it doesn’t already exist) A unit test case (if it doesn’t already exist) A functional test case A functional test case

Scaffolding demo (In case you’re unfamiliar with Rails scaffolds)

Start a new Rails application > rails bugcatcher... > cd bugcatcher >

Add a new model > script/generate model Issue exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/issue.rb create test/unit/issue_test.rb create test/fixtures/issues.yml create db/migrate create db/migrate/001_create_issues.rb >

Describe the database table behind your model # (Editing the file 001_create_issues.rb) class CreateIssues < ActiveRecord::Migration def self.up create_table :issues do |t| t.column :created_at, :datetime t.column :subject, :string t.column :body, :text t.column :assigned_to, :string end def self.down drop_table :issues end

Create the database and table > mysqladmin --user=root create bugcatcher_development > rake migrate == CreateIssues: migrating =========================== -- create_table(:issues) -> s == CreateIssues: migrated (0.1100s) ================== >

Build a scaffold for your model and point your browser at it > script/generate scaffold Issue... > script/server => Booting WEBrick... => Rails application started on => Ctrl-C to shutdown server; call with --help for options [ :00:00] INFO WEBrick [ :00:01] INFO ruby ( ) [i386-mswin32] [ :00:02] INFO WEBrick::HTTPServer#start: pid=4056 port=3000

Voilà—you’re on Rails

What’s wrong with scaffolding? Not much Not much Scaffold controllers are cluttered with too many actions Scaffold controllers are cluttered with too many actions Scaffold URL s are both pretty and hackable, but they can be made more so Scaffold URL s are both pretty and hackable, but they can be made more so Scaffold views do not degrade gracefully in the absence of JavaScript Scaffold views do not degrade gracefully in the absence of JavaScript

Scaffold: Too many actions URLResult /issues /issues/list Lists existing issue records /issues/newShows an empty issue /issues/createInserts a new issue /issues/show/99Shows the issue having ID 99 /issues/edit/99Shows an issue form for ID 99 /issues/update/99Updates the issue having ID 99 /issues/destroy/99Deletes the issue having ID 99

Trestle: No clutter URLMethodResult /issues GET / POST Lists existing issue records /issues/new GET Shows an empty issue POST Inserts a new issue /issues/99 GET / POST Shows the issue having ID 99 /issues/99/edit GET Shows an issue form for ID 99 POST Updates the issue having ID 99 /issues/99/destroy GET Redirects to edit with a notice POST Deletes the issue having ID 99

Scaffold: Pretty and hackable URL s /issues/edit/99 is Rubyish in that it reads well, but it breaks Google Toolbar’s Up One Level because /issues/edit leads nowhere /issues/edit/99 is Rubyish in that it reads well, but it breaks Google Toolbar’s Up One Level because /issues/edit leads nowhere Savvy users will explore your application by toying around with URL s—you should encourage this Savvy users will explore your application by toying around with URL s—you should encourage this URLs are an important part of your UI —make them as usable as possible URLs are an important part of your UI —make them as usable as possible

Trestle: Prettier and hackabler URL s /issues/99/edit has no invalid “parent directories” (/issues and /issues/99 work) /issues/99/edit has no invalid “parent directories” (/issues and /issues/99 work) Your application may have more complex URL s, but try to make all reasonable variations of any URL a valid destination: Your application may have more complex URL s, but try to make all reasonable variations of any URL a valid destination: –/ people / njonsson / issues / 99 / edit –/ calendar / 2006 / 5 / 13 ? view=me & feed=rss20 –/ dashboard / customize / widgets / top_right

Scaffold: JavaScript required The Destroy link on the list view produces an HTTP POST request with the help of JavaScript (an tag is transformed into a ) The Destroy link on the list view produces an HTTP POST request with the help of JavaScript (an tag is transformed into a ) If JavaScript is not present then the remains and a GET request is made instead of POST If JavaScript is not present then the remains and a GET request is made instead of POST The scaffold controller silently ignores the request— this is an acceptable response to Google Web Accelerator but is less than friendly to a person typing in his browser’s address bar The scaffold controller silently ignores the request— this is an acceptable response to Google Web Accelerator but is less than friendly to a person typing in his browser’s address bar

Trestle: JavaScript cool but not required The Destroy link works the same way on a trestle’s list view as it does on a scaffold’s list view The Destroy link works the same way on a trestle’s list view as it does on a scaffold’s list view But trestle’s edit view adds a Destroy button at the bottom of the form But trestle’s edit view adds a Destroy button at the bottom of the form The trestle controller redirects a GET request to the edit view, and it provides a flash notice instructing the user to click the Destroy button The trestle controller redirects a GET request to the edit view, and it provides a flash notice instructing the user to click the Destroy button

Trestle: Show me the tests test_list test_list test_new_using_get test_new_using_get test_new_using_post test_new_using_post test_show test_show test_show_without_id test_show_without_id test_edit_using_get test_edit_using_get test_edit_using_post test_edit_using_post test_edit_without_id test_edit_without_id test_destroy_using_get test_destroy_using_get test_destroy_using_post test_destroy_using_post test_destroy_without_id test_destroy_without_id Trestle controllers start your application off on the right foot with functional tests of the controller’s behavior.

Get trestle now > gem install trestle_generator Attempting local installation of ‘trestle_generator’ Local gem file not found: trestle_generator*.gem Attempting remote installation of ‘trestle_generator’ Updating Gem source index for: Successfully installed trestle_generator >

Feed back Visit trestle.rubyforge.org Visit trestle.rubyforge.org Send mail to Send mail to