Skip to content

Instantly share code, notes, and snippets.

@takeru
Forked from woodie/README.rdoc
Created March 9, 2010 03:38
Show Gist options
  • Save takeru/326129 to your computer and use it in GitHub Desktop.
Save takeru/326129 to your computer and use it in GitHub Desktop.

Rails 2.3.5 on App Engine (TinyDS)

Recently, Takeru Sasaki was able to patch the Rails 2.3.5 calls to rubygems, and now we have it working on App Engine. He also created a datastore adapter called TinyDS. I just created an integration plugin called Rails_TinyDS that provides certain ActiveRecord method calls for Rails 2.3.5 generated scaffold.

See the DataMapper version also: gist.github.com/268192

Install the Development Environment

The gems for the development environment include a pre-release appengine-tools gem that provides a pre-release version of jruby-rack.

sudo gem install google-appengine

Install Rails 2.3.5 with required patches

Create a folder for your app

mkdir rails_app; cd rails_app

Download the setup script

curl -O http://appengine-jruby.googlecode.com/hg/demos/rails2/rails2_appengine.rb
  or
Open this page: http://appengine-jruby.googlecode.com/hg/demos/rails2/ and "Right Click and Save"

Run the setup script

ruby rails2_appengine.rb tiny_ds

Working with Your Rails App

Start development server

./script/server.sh

Open local console

./script/console.sh

Publish to production

./script/publish.sh

Support for generators

We disable rubygems in the development environment, and the generators from Rails 2 perform various Gem dependency checks that are too difficult to patch, so we run the generators from the MRI.

sudo gem install rails -v "2.3.5"
sudo gem install rails_tiny_ds 
sudo gem install activerecord-nulldb-adapter

Generate a restful controller and add it to config/routes.rb

./script/generate scaffold article title:string summary:text url:string \
pages:integer -f --skip-migration

Generate a model for TinyDS

./script/generate td_model article title:string summary:text url:string \
pages:integer -f

You’ve created a RESTful controller, and a TinyDS model

class Article < TinyDS::Base
property :title, :string
property :summary, :text
property :url, :string
property :pages, :integer
property :created_at, :time
property :updated_at, :time
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment