ActiveScaffold: How to get started
When I took a first peek at ActiveScaffold, I had no idea into how much trouble I’d run before creating beautiful AND working backends for my applications. I had LOTS of research to do to get around some rather nasty issues and I want to provide you with some info on how to get stuff done.
Some prerequisites:
I use Rails 2.3.4 at the time this is posted and my gem list shows:
actionmailer (2.3.4)
actionpack (2.3.4)
activerecord (2.3.4)
activeresource (2.3.4)
activesupport (2.3.4)
flickraw (0.7.1)
json (1.1.9)
locale (2.0.4)
locale_rails (2.0.4)
mime-types (1.16)
mysql (2.8.1)
rack (1.0.0)
railroad (0.5.0)
rails (2.3.4)
rake (0.8.7)
thoughtbot-paperclip (2.3.1)
Installation:
To install AS, open a shell and type:
ruby script/plugin install git://github.com/activescaffold/active_scaffold.git
Installs AS and all the necessary stuff
ruby script/plugin install git://github.com/rails/in_place_editing.git
Ooops, in place editing was missing – so let’s install it.
ruby script/plugin install --force git://github.com/lackac/render_component.git -r rails-edge'
Ooops again, render_component was taken out of Rails so subforms wouldn’t work – let’s get around this by installing lackac’s plugin (thanks!)
OK, basically, you are set. What now?
The ActiveScaffold website (www.activescaffold.com) and especially their API docs are your bible. So read them, re-read them and re-re-read them while building stuff with AS – you will need the (rudimentary) tipps included there.
Ok, now let’s start with integrating AS into our app. Let’s say you have a basic application which already has a master layout. Put this tag into the
<%= active_scaffold_includes %>
It includes all the magic needed for AS. To continue, you should have a resource we can work on, in this case I created a resource named “customer” to store some customer info in it and work on it with AS:
ruby script/generate resource customer name:string phone:string email:string description:string is_active:boolean
Migrate the data now:
rake db:migrate
Edit your customers_controller.rb in app/controllers and put
active_scaffold :customer do |config|
end
right after
class CustomerController < ApplicationController
to make AS aware that it should take care of our customers. Now open config/routes.rb and add :active_scaffold => true right after the customer resource. When you start your server and call /customers, you now should see AS in action. Congratulations, this was the first part
Related posts
Posted on 05.11.2009 at 18:49
thanks for commenting!

Posted on 05.11.2009 at 18:41
Well written, thank you for this