Skip to content

Rails 3 Walkthrough Part 1

dturnbull edited this page Dec 2, 2010 · 5 revisions

Create a new Rails 3 app without any javascript framework. We'll use a scaffold to check things out.

rails new myapp --skip-prototype
cd myapp
rails generate scaffold Employee name:string department:string notes:text
rake db:migrate
rails s

Check things out. Create a record. Note that you can't delete the record because we didn't install any javascript.

http://localhost:3000/employees

Next we install the Googlyscript development tool. Modify three files.

# Gemfile
gem 'googlyscript'
# config.ru
use Googly::Middleware
# config/environments/development.rb
Googly.script '/dev/goog', :goog
Googly.script '/dev/googly', :googly
Googly.script '/dev/myapp', 'app/javascripts'

Add the example script to your layout template.

<!-- app/views/layouts/application.html.erb -->
<%= javascript_include_tag '/dev/googly/rails_ujs.js' %>

Restart the server and you'll be able to delete records. You'll learn how to upgrade the text area to a wysiwyg editor in Rails 3 Walkthrough Part 2.

Clone this wiki locally