Difference between revisions of "Emergent Web Technologies Spring 2009 Class 9"

esse quam videri
Jump to: navigation, search
(New page: == Introduction == We already talked about getting remote data with JavaScript using JSONp and jQuery, but, until now, we haven't been able to use Ajax. Now that we can create simple sites...)
 
m
Line 11: Line 11:
  
 
3. Navigate to the new rails site and create the scaffold for a simple locations database
 
3. Navigate to the new rails site and create the scaffold for a simple locations database
   cd ajax_2
+
   cd ajax
  
 
   ruby script/generate scaffold Location name:string address:string city:string state:string zip:string
 
   ruby script/generate scaffold Location name:string address:string city:string state:string zip:string

Revision as of 20:54, 1 April 2009

Introduction

We already talked about getting remote data with JavaScript using JSONp and jQuery, but, until now, we haven't been able to use Ajax. Now that we can create simple sites with Ruby on Rails I'll cover how to write some simple Ajax code to make your pages more dynamic.

Activity 1

With this activity we'll take a regular scaffolded Rails site and add a little bit of Ajax. The idea is that the site is designed to work without Ajax, but if the user has JavaScript enabled, we can make it a little bit more dynamic.

1. Open Instant Rails and the Ruby console window

2. Generate a new Rails site

 rails ajax

3. Navigate to the new rails site and create the scaffold for a simple locations database

 cd ajax
 ruby script/generate scaffold Location name:string address:string city:string state:string zip:string
rake db:migrate

4. Make sure that your site works by starting the server

ruby script/server

And then open the link to your site http://localhost:3000/locations