ActiveScaffold :: Wiki
Dynamic conditions_for_collection

ActiveScaffold conditions_for_collection explanation

Here’s a simple way to dynamically limit your scaffold.

Let’s say you have a scaffold that shows users, offices, and locations. Some sample data would be:

user id: 1
user: Peter
office id: 1
office: Finance
location id: 1
location: Atlanta
------
user id: 2
user: Paul
office id: 1
office: Finance
location id: 2
location: Tampa
------
user id: 3
user: Marty
office id: 2
office: Human Resources
location id: 2
location: Tampa

Sometimes you want to show everyone in Tampa. Sometimes you want to show everyone in the Finance office. An easy way to change the scaffold is to use define actions that change the conditions_for_collection.

require 'active_scaffold'
class SampleController < ApplicationController
  active_scaffold :user do |config|
    config.actions.exclude :create, :update, :show, :delete
    config.columns = ['name', 'office', 'location']
  end
  def office
    @condition = "offices.id = #{params[:id]}" 
    index
  end
  def location
    @condition = "locations.id = #{params[:id]}" 
    index
  end
  def conditions_for_collection
    @condition
  end
end

Now you can use the following urls:

/sample/
/sample/office/1
/sample/location/1

Why would you use this? It may save you from having to define multiple controllers that show the same information.
health insurance
auto insurance
insurance price quotes