Ruby on Rails Creating a Rails Application Carol E Wolf CS396X.

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Introduction to Rails.
Advertisements

Java Script Session1 INTRODUCTION.
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.
Housing and Dining Online by Andrew Gorges. Outline  Overview of PHP  Overview of MySQL  Using PHP  Using MySQL  PHP and MySQL together  Production.
Chapter 15 © 2010 by Addison Wesley Longman, Inc Origins and Uses of Ruby - Designed by Yukihiro Matsumoto; released in Use spread rapidly.
B.Sc. Multimedia ComputingMedia Technologies Database Technologies.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Computing Concepts Advanced HTML: Tables and Forms.
Methods for Rails. File Structures This is taken directly from app Holds all the code that's specific.
Multiple Tiers in Action
Lecture 4: Introduction to PHP 3 PHP & MySQL
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.
Dynamic Web site With PHP and MySQL. MySQL The combination of MySQL database and PHP scripting language is optimum for building dynamic websites. MySQL.
1 Open a Lotus Notes Database in the Lotus Notes Client.
Ruby on Rails: An Introduction JA-SIG Summer Conference 2007 Michael Irion The University of Tulsa.
CpSc 462/662: Database Management Systems (DBMS) (TEXNH Approach) HTML Basics James Wang.
Rails and Grails. To get started Make sure you have java installed You can get the sdk and jre at:
1 Working with MS SQL Server. 2 Objectives You will be able to Use Visual Studio for GUI based interactive access to a Microsoft SQL Server database.
CSCI 6962: Server-side Design and Programming
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.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Web Application Programming Carol Wolf Computer Science.
Views Carol Wolf Computer Science. Extended Ruby  Views files are written in extended Ruby, erb.  They end in.html.erb.  Ruby code is intermixed with.
>> Introduction to HTML: Tags. Hyper - is the opposite of linear Text – words / sentences / paragraphs Mark-up – Marking the text Language – It is a language.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
Introduction to HTML. What is a HTML File?  HTML stands for Hyper Text Markup Language  An HTML file is a text file containing small markup tags  The.
HTML Concepts and Techniques Fourth Edition Project 6 Using Frames in a Web Site.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
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.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
Installing and Using MySQL and phpMyAdmin. Last Time... Installing Apache server Installing PHP Running basic PHP scripts on the server Not necessary.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Installation and Testing.
OPAC Training aid (Library solutions & Library world)
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.
Chapter 15 © 2009 by Addison Wesley Longman, Inc Overview of Rails - Rails is a development framework for Web-based applications - Rails is written.
HTML ( HYPER TEXT MARK UP LANGUAGE ). What is HTML HTML describes the content and format of web pages using tags. Ex. Title Tag: A title It’s the job.
Rails & Ajax Module 5. Introduction to Rails Overview of Rails Rails is Ruby based “A development framework for Web-based applications” Rails uses the.
RUBRIC IP1 Ruben Botero Web Design III. The different approaches to accessing data in a database through client-side scripting languages. – On the client.
Chapter 15 © 2013 by Pearson Overview of Rails - Rails is a development framework for Web-based applications - Based on MVC architecture for applications.
Using Frames in a Web Site Project 6. Project Objectives Project 6: Using Frames in a Web Site 2 Define terms related to frames Describe the steps used.
Create, Update and Delete Carol Wolf Computer Science.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Headings are defined with the to tags. defines the largest heading. defines the smallest heading. Note: Browsers automatically add an empty line before.
1 Dr Alexiei Dingli Web Science Stream Installing ROR.
Adding Data to a Database Table Carol Wolf Computer Science.
CS 160 and CMPE/SE 131 Software Engineering February 9 Class Meeting Department of Computer Science Department of Computer Engineering San José State University.
Working With Database Library And Helpers. Connecting to your Database First you need to set parameters in you database.php file residing in config folder.
The Controller Carol Wolf Computer Science. Rails generate commands  Using the generate command, you can create a number of useful objects.  Rails:
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.
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.
Generating XML Data from a Database Eugenia Fernandez IUPUI.
PHP and SQL Server: Connection IST 210: Organization of Data IST2101.
COM621: Advanced Interactive Web Development Lecture 10 PHP and MySQL.
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.
CMPE/SE 131 Software Engineering September 1 Class Meeting Department of Computer Engineering San José State University Fall 2016 Instructor: Ron Mak
Rep change 1590 (ver 18) Access to Google books
Microsoft Office Illustrated
Chapter 15 Introduction to Rails.
Chapter 7 Searching Your Products
Training & Development
CMPE/SE 131 Software Engineering February 2 Class Meeting
Presentation transcript:

Ruby on Rails Creating a Rails Application Carol E Wolf CS396X

Ruby Console Window First choose Rails Applications Next select Open Ruby Console Window At the prompt, type rails apps_name For example: rails library This creates a full directory system in the folder rails_apps.  Console Window

Rails directory system

Important folders  app  controllers – sits between client and database  helpers – module with common ruby code  models – code to interface with the database  views – web pages containing html and erb  db – contains database  migration – methods to change the database  script  console – interactive console window for ruby code  dbconsole – interactive console window for the database  generate – methods to generate scaffolding and migrations  server – activates server to be used with localhost

Adding a table to the database  You can use the scaffold command to set up your database.  The database is created when you create the application.  Type the following to create a table called books.  ruby script/generate scaffold book isbn:string author:string title:string  Note that if you call it book, rails automatically makes it books.  This creates the file _create_books.rb in the db/migrate folder, where the numbers are a time stamp.  Then type  rake db:migrate  The rake command executes all the ruby files in the migrate folder.  Rails includes a primary id field that is automatically incremented when you add rows to the database.

The file, schema.rb  Rake adds a ruby file to the db folder called schema. Lines beginning with # are comments. # This file is auto-generated from the current state of the database. # (Additional comments omitted.) ActiveRecord::Schema.define(:version => ) do create_table "books", :force => true do |t| t.string "isbn" t.string "author" t.string "title" t.datetime "created_at" t.datetime "updated_at" end

View the contents of the database  To begin with, the books table is empty. Bring up the server to access it.  ruby script/server  The server that comes with InstantRails is called mongrel. It is a version of the open source apache server.  Point your browser to  where localhost is the name for the IP address (Use that if your computer does not recognize localhost.)  localhost is often called the local loop.

The first web page  The first web page is just the title of the table.  It includes a heading and a link to a New book page.  Click it to add data to the table.

The New book page  The new book page provides text fields with labels.  You can use these to add data.  Just fill in the fields and click Create.  When done, it will take you to a third page that shows what you added.

The show page and the index after adding a book to the table.

The index.html.erb page uses embedded ruby code. Listing books ` Isbn Author Title 'Are you sure?', :method => :delete %>

Explanation of some of the index page code  The tag creates a table with headers enclosed by …, rows by …, and columns by …  The embedded ruby code is enclosed by   This line displays the data in the book column.  The controller retrieves the data in a result set, a two dimensional array. It is displayed on the page using a ‘for’ loop.   The sign is used to indicate a variable.  The line generates the html code New book.

Header code added by rails to the beginning of the web pages. It also adds a foot to the end. Books: index