Friday, February 29, 2008

ExtJS & Rails - ExtJS scaffold generator installation script

What?
An automatic installation script for the ExtJS scaffold generator plugin (demo keynotes)to get you up and running.

Why?
Rails' scaffolding gets you up an running lightning fast. ExtJS is a wonderful javascript desktop library. Let's marry them

How?
Run the following script - it will

  • Create the rails application
  • Install the ExtJS scaffolding plugin
  • Download and install ExtJS for your application
  • Generate two sample models - posts and purchases
  • Setup the database
  • Create links to the sample models on the application landing page
  • Run the server
Then all you have to do is point your browser to http://localhost:3000, assuming the server is running on your computer.

Have fun!

# Create the app
rails ext_scaffold_setup
cd ext_scaffold_setup

# Install the plugin and extjs
script/plugin install http://rug-b.rubyforge.org/svn/ext_scaffold
curl -O http://extjs.com/deploy/ext-2.0.2.zip
unzip -q ext-2.0.2.zip
rm ./ext-2.0.2.zip
mv ./ext-2.0.2 ./public/ext

# Generate some scaffolds - posts and purchases
./script/generate ext_scaffold post title:string body:text
./script/generate ext_scaffold purchase order_id:integer amount:decimal description:text

# Create the database for the models
rake db:migrate

# Create links to the models on the landing page
echo '<title>ExtJS Scaffold generator sample</title>echo '<style type="text/css" media="screen">a {text-decoration:none; color:#abc}</style><a href="http://www.blogger.com/posts">Posts</a> <a href="http://www.blogger.com/purchases">Purchases</a>' > ./public/index.html

# All set, run the server!
./script/server

Point your browser to http://localhost:3000, and you're good to go.

6 comments:

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

the ExtJS scaffold generator appears to be broken in rails 2.1.0, I tried the above method and the grid didn't show anything after a record had been created. Forcing the application to use rails 2.0.2 caused it to work properly (though forcing it wasn't easy either).

I know this isn't really the spot for a bug report but I don't know where you're tracking the bugs for this or if its even being actively developed.

Marcus Westin said...

Hey Luke,

I'm happy to hear that someone's finding this useful - and sadly have to say that it was a 30 minute hack that never had any active development and never will. There's really nothing else to it than the script, so what I would recommend is going through the steps one by one, finding where it fails, fixing that one line, and try it again.

If you do, please let me know and I'll re-post (with you credited, of course).

Cheers!

Senthil Nayagam said...

in Rails 2.1 in initializers/new_rails_defaults has this line
ActiveRecord::Base.include_root_in_json = true
which causes JSON to be formed which is different from what is defined in scaffold

changing it to "false" solves the problem

Unknown said...

You can try out GridPanel from the <a href="http://blog.writelesscode.com>Netzke framework</a> - it's like Ext/Rails scaffolding with many extras, highly configurable and extendible. Demo/tutorial here: http://netzke-demo.writelesscode.com/grid_panel/demo

Mary Shane said...

The scaffold in this case was that I made a connection to cars and place in a sequence. I said you can put a yellow car first, second or third, or a blue car, or a red one. You can look at how many different places you can put a car in a row.

Scaffold