Rails 2.0

9 downloads 58 Views 970KB Size Report
Install the Aptana IDE. • You need the Java Runtime - http://java.sun.com/javase/ downloads/index.jsp. • Aptana - http://www.aptana.com/download/index.php.
Rails 2.0 Barry Burd [email protected]

This slide presentation © 2008 Barry Burd Copyrights for Ruby, Rails and other material are held by their respective owners.

1

Install Ruby and Rails • Ruby - http://www.ruby-lang.org/en/downloads/ • Rails -

© 2008 Barry Burd

2

Install SQLite • http://www.sqlite.org/download.html

Copy the uncompressed files to your ruby\bin directory

© 2008 Barry Burd

3

Install SQLite (continued)

© 2008 Barry Burd

4

Install the Aptana IDE • You need the Java Runtime http://java.sun.com/javase/downloads/index.jsp • Aptana - http://www.aptana.com/download/index.php

© 2008 Barry Burd

5

Install the RadRails plugin within Aptana

© 2008 Barry Burd

6

Configure RadRails

© 2008 Barry Burd

7

Configure RadRails

© 2008 Barry Burd

8

Configure RadRails

© 2008 Barry Burd

9

The Aptana IDE • Based on Eclipse – – – – –

View Editor Part Area Perspective

© 2008 Barry Burd

10

R u b y P e r s p e c t i v e © 2008 Barry Burd

11

R a i l s P e r s p e c t i v e

© 2008 Barry Burd

12

D a t a P e r s p e c t i v e

© 2008 Barry Burd

13

D e b u g P e r s p e c t i v e © 2008 Barry Burd

14

Watch a movie...

http://www.burdbrain.com/RubyOnRails/Rails2.wmv

© 2008 Barry Burd

15

RadRails Perspective

© 2008 Barry Burd

16

Create a new Rails Project

© 2008 Barry Burd

17

Name the project

© 2008 Barry Burd

18

Rails creates folders and files

© 2008 Barry Burd

19

Create a database

© 2008 Barry Burd

20

Generate a scaffold

© 2008 Barry Burd

21

Migrate the database Create table(s) and column(s)

© 2008 Barry Burd

22

Start the project’s Web server

© 2008 Barry Burd

23

Visit the Web server’s Welcome page

© 2008 Barry Burd

24

Visit the “list” page

© 2008 Barry Burd

25

Add a new record

© 2008 Barry Burd

26

© 2008 Barry Burd

27

Show an existing record

© 2008 Barry Burd

28

Edit an existing record

© 2008 Barry Burd

29

Several types of fields

© 2008 Barry Burd

30

The Migration File Bookstore\db\migrate\001_create_books.rb

© 2008 Barry Burd

31

Bookstore\config\database.yml

© 2008 Barry Burd

32

The Model Code Bookstore\app\models\book.rb

© 2008 Barry Burd

33

The Controller Code Bookstore\app\controllers\books_controller.rb "if the client wants HTML in response to this action, just respond as we would have before, but if the client wants XML, return them the list of people in XML format." (Rails determines the desired response format from the HTTP Accept header submitted by the client.)”

Let the instance variable (the attribute) @book be the record you get when you look for a record whose id matches the incoming id parameter.

© 2008 Barry Burd

34

The Controller Code Bookstore\app\controllers\books_controller.rb

© 2008 Barry Burd

35

The Controller Code Bookstore\app\controllers\books_controller.rb

© 2008 Barry Burd

36

The Controller Code Bookstore\app\controllers\books_controller.rb

© 2008 Barry Burd

The Index Page Bookstore\app\views\books\index.html.erb

View Source © 2008 Barry Burd

View Source Books: index © 2008 Barry Burd

39

View Source

Listing books

Title Isbn
Ruby on Rails For Dummies 12233355566622444 Show Edit