CS 498 Selected Topics in Computer Science I

apatheticyogurtSoftware and s/w Development

Dec 13, 2013 (3 years and 8 months ago)

84 views

1

International University
of Sarajevo

FENS

CS 498 Selected Topics in Computer Science I

Spring 2012/2013

Course instructor: Dr. Jasminka Hasic Telalovic

Chapter 6: Creating the Application

2

International University
of Sarajevo

Create interface to add, delete and edit products


rails new depot


cd depo and examine directory structure


Create database (SQLite 3


no user account and passwords to deal
with)


Create model, views controller for products


rails generate scaffold Product title:string description:text
image_url:string price:decimal


add t.decimal :price, precision: 8, scale: 2 to migration


rake db:migrate (applies all unapplied migrations to the database


i.e. creates products table)


start server (rails server)


open http://localhost:3000/products

3

International University
of Sarajevo

Create interface to add, delete and edit products


Change the view _from.html: <%= f.text_area
:description, rows:6 %>


Add some products through interface


rake test (runs simple unit and functional test
scaffold has created)

4

International University
of Sarajevo

Making prettier interface


db/seeds.rb for default test data


rake db:seed


Look at app/assets/stylesheets


In views/layouts/application.html.rb add:

<body class='<%= controller.controller_name %>'>


In app/views/products/index.html.erb