Activescaffold empower user to configure list


Mr Bonefish created a plugin called active_scaffold_config_list which empowers the user to hide and show columns in list view. That s a really valuable feature and should still exist in the world of rails 3, I thought.

You may find the result of my thoughts in a fork of active_scaffold_config_list.
You are still able to hide and show columns. In addition I ve empowered the user to change the order of list columns by simple drag and drop. Please note that you cannot drag and drop the columns itself, but instead you can drag and drop the column names in the config_list action form.

Let me guide you through the steps to install and configure config_list plugin.

We will start with installation of active_scaffold_config_list plugin.

rails plugin install git://

Afterwards, we have to add config_list action to our controller.

active_scaffold :player do |conf|
  conf.actions << :config_list

Yes and thats it. You should see a new collection action_link, which empowers your users to configure list view as they like.

Bonefish implemented another neat feature, which survived transformation to rails 3. You may define a set of default_columns for your list_view.
That s really useful if you ve got tons of list columns available, but as a default you would only like to show a subset of them.

conf.config_list.default_columns = [:name, :salary, :team]

Activescaffold how to automatically open a nested link


From time to time I was confronted with the following feature request by my users:
If I filter list view for a specific record, could nt you open a nested link automatically?

There a several approaches to achieve this and you have to decide if you would like to do it on server or client-side with corresponding pro’s and con’s.

I ve implemented a server side version which requires render_component plugin.
However, that one is installed automatically in my howto application.

Let me show you how it works in a quite short example:

class TeamsController < ApplicationController
  active_scaffold :team do |conf|
    conf.list.nested_auto_open = {:players => 1}

Our starting point is a nested link to players model.
Next line is doing all the magic, we configured that players nested link should be automatically opened if there is only 1 team record in list view.
You could also pick 2 or even 10 records in list views.

Human Conditions with Field Search


Today, I would like to introduce a new experimental feature. Currently, if you are using field_search you can see in top row of your record set that your list is currently filtered. However, you may not remember current search criteria. This is why I have added a little feature called “human conditions”, which will try to inform the user about the current search criteria.

Just try it out, it s fairly easy to activate.

class TeamsController < ApplicationController
  active_scaffold :team do |conf| 
    conf.actions.swap :search, :field_search 
    conf.field_search.human_conditions = true 

One Step rails app with activescaffold installation


At the beginning I thought, great my process described in my post how to setup activescaffold with rails 3 is quite easy and only consists of a view steps. Unfortunetly, I had to realize that even these few steps are too many if you have to do that frequently.

Therefore I ve tried to further reduce steps it takes to install my little howto application. I ve managed to get it down to one step (if you do not count downloading a ruby script :-))

That s a real time safer for me and will be for you if you are following my posts and try these things out. In addition it can be used to install any new activescaffold enabled rails 3 app.

You may find that install script at the following location: One Step Activescaffold

If you want to try it out just download the following file: and run it on your computer without any options.

At the end you are a proud creator of my little how-to application. you just have to call ‘rails s’ to start the application.

If you like it you can use it even for your own apps. This little script takes several arguments, these empower you to set application name, js_library, your preferred database system and db user and password.
If you would like to create your own models instead of my player and team ones… Sure no problem. You just have to create a special file in the same directory which includes the required commands to create these models.

Let’s take a look at some examples:

ruby one_step_activescaffold_app.rb

That s the default, which creates my little how-to.

ruby one_step_activescaffold_app.rb my_new_app jquery mysql

Creates my little how-to with the name ‘my_new_app’ using mysql and jquery.

ruby one_step_activescaffold_app.rb my_new_app jquery postgres john top_secret

Same as before, but using postgres and db_user is ‘john’ and password is ‘top_secret’

puts %x[rails g active_scaffold coach name:string]

ruby one_step_activescaffold_app.rb

Creates my little how-to, but instead of creating team and player model, we create a coach model.

ActiveScaffold and Trees with Ancestry Plugin


Today I would like to show how easy it can be to setup a tree structure with activescaffold.

At the end of this post we should have a tree structure in which we can CRUD elements, even changing the parent of a child.
In addition we can sort children of a parent by drag and drop.

As usual we will need my little how-to application.

1. Create a new menu model

rails g active_scaffold Menu name:string action:string position:integer ancestry:string
rake db:migrate

position attribute is needed for sorting and ancestry attribute for ancestry plugin.

2. Install plugins

rails plugin install git:// 
rails plugin install git:// 
rails plugin install git:// 

3. Include ancestry into Menu Model


class Menu < ActiveRecord::Base

4. Configure Menu Controller


class MenusController < ApplicationController
  active_scaffold :menu do |conf|
    conf.nested.add_scoped_link(:children)  #nested link to children


  # If nested let active_scaffold manage everything
  # if not just show all root nodes
  def beginning_of_chain 
    nested? ? super : active_scaffold_config.model.roots 

  # Assign parent node to just created node
  def after_create_save(record) 
    if (nested? && nested.scope) 
      parent = nested_parent_record(:read) 
      record.send("#{nested.scope}").send(:<<, parent) unless parent.nil? 

5. Starting server and creating menu records

Create records, edit records, delete records,…..

6. Something is missing…. Sorting


class Menu < ActiveRecord::Base

You have to restart your server to enable sorting feature in your UI.