Skip to content
This repository

Installing on Rails 3.1 or 3.2

(For Rails 3.0 and 2.3 see older versions)

Use the gem

gem install active_scaffold

Add it to your Gemfile of course:

gem 'active_scaffold'

Then you need to add active_scaffold to your assets pipeline, by adding it as a comment at the bottom of the following two ‘manifests’ files:

in Rails.root/app/assets/stylesheets/application.css

*= require active_scaffold

in Rails.root/app/assets/javascripts/application.js

//= require active_scaffold

Your First ActiveScaffold

Use active_scaffold or active_scaffold_controller generators instead of resource or controller generators in rails 3. They will create controllers with active_scaffold enabled, as well as active_scaffold routes:

rails g active_scaffold Model attr1:type attr2:type
rake db:migrate

That’s it! Your first ActiveScaffold is up and running.

Starting to Configure

Your scaffold should be up and running with default everything right now. Not quite how you want it?

First let’s introduce the global config block. You probably noticed that the active_scaffolding includes everything in the table. Let’s remove a few of these columns with one easy config block. Create an active_scaffold.rb initializer in config/initializers. And don’t forget to restart your application whenever you make changes to this file.

# config/initializers/active_scaffold.rb
ActiveScaffold.set_defaults do |config| 
  config.ignore_columns.add [:created_at, :updated_at, :lock_version]

Let’s have a look at the local config block. This block goes in the model’s corresponding controller. The config block for the Company model goes in the CompaniesController. ActiveScaffold restricts one model per controller. Now for an example:

class CompaniesController < ApplicationController

  active_scaffold :company do |config|
    config.label = "Customers"
    config.columns = [:name, :phone, :company_type, :comments]
    list.columns.exclude :comments
    list.sorting = {:name => 'ASC'}
    columns[:phone].label = "Phone #"
    columns[:phone].description = "(Format: ###-###-####)"


ActiveScaffold tries to be flexible: change the labels, decide which columns to include, control the columns included per-action, define a default sort order, specify a column label and a column description. Check the API docs to see what’s possible!

Something went wrong with that request. Please try again.