Getting ActiveScaffold to work under Ruby on Rails 2.3

I had started an application using Ruby on Rails and I wanted to try out ActiveScaffold as a replacement for standard scaffolding. I’d seen ActiveScaffold in action before but I’d never used it. I knew that ActiveScaffold dynamically generates application pages using a standard format, and if you change the format it updates all of your application’s pages — unlike standard scaffolding where you have to tweak each and every page. For the application I’m working on it sounded like a huge time-saver, so I decided to try it out.

I was trying to install ActiveScaffold for Ruby on Rails using the steps shown on the Active Scaffold – Getting Started tutorial. However, when I installed ActiveScaffold using the instructions the Mongrel web server I use for development would die as soon as I tried to restart it, dumping a large list of errors:

earl@earl:~/projects/TotalWorldDomination > script/server
=> Booting Mongrel
=> Rails 2.3.2 application starting on
module/aliasing.rb:33:in `alias_method': undefined method `_pick_template' 
for class `ActionView::Base' (NameError)
        from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
core_ext/module/aliasing.rb:33:in `alias_method_chain'

… and the error messages continued, filling up the entire screen.

I quickly figured out that the problem was that I was using Rails 2.3.2, and the release version of ActiveScaffold was for Rails 2.2.x. The tutorial was for Rails 2.2.x, not 2.3.x.

Since I’d just commited all of my changes to my Subversion repository before installing ActiveScaffold I reverted to the previous version of my application, removing any files installed by ActiveScaffold.

I checked the README for ActiveScaffold on GitHub and installed the following branches:

script/plugin install git:// -r master
script/plugin install git:// -r rails-2.3

After that Mongrel loads just fine:

earl@earl:~/projects/TotalWorldDomination > script/server
=> Booting Mongrel
=> Rails 2.3.2 application starting on
=> Call with -d to detach
=> Ctrl-C to shutdown server

Following the tutorial I added this to my layout:

<%= javascript_include_tag :defaults %>
<%= active_scaffold_includes %>

And I added this to one of my controllers (just so I could test out ActiveScaffold with one model):

  layout "admin"

At this point if I try to pull up a view for the controller I just modified I get a “Template is missing – Missing template admin.erb in view path vendor/plugins/active_scaffold/frontends/default/views” error.

Active Scaffold - missing admin view

This error is misleading, since (checking GitHub) there are no admin.* files in active_scaffold/frontends/default/views in any of the four ActiveScaffold branches. It’s not a view that comes built into ActiveScaffold, even though the tutorial makes it sound like a built-in layout, it’s the name of a layout file for your application.

In my case the layout that I’d modified in the previous step was application.html.erb, and it was the only layout in my small application. I made a copy of the file named admin.html.erb:

cd app/views/layouts
cp application.html.erb admin.html.erb

Then following advice I found in the ActiveScaffold forums I commented out everything in all of my standard-scaffold-generated controllers, leaving only the lines:

  layout "admin"

… in between the “class” and “end” lines for each controller.

Once I did that ActiveScaffold worked fine.

One note: If you do get any “Request Failed (code 500, Internal Error)” errors, check log/development.log for hints about what’s going on, it’ll usually tell you what the problem is.

Hope you found this useful.

7 thoughts on “Getting ActiveScaffold to work under Ruby on Rails 2.3

  1. After all these things, the forms will not work still because the get requests won’t be able to find the appropriate method in the controller. An error like this appears in the log.

    ActiveRecord::RecordNotFound (Couldn’t find Site with ID=show_search):

    For this to work set the active_scaffold flag to true for the resource in your routes.rb as follows:

    map.resources :areas, :active_scaffold => true

  2. I only had to add “:active_scaffold => true” to get pagination to work. If your list did not paginate then you don’t need it. If your list does paginate then page 2, etc will only work with this addition.

  3. Thanks for posting. I was hunting high and low to get column sorting working with Rails 2.3.2 and the routing example finally solved it.

  4. When :active_scaffold => true is added to an existing route in routes.rb , routes are added to make search and column sorting work.
    Run “rake routes” command and you will see all the routes required for the search and column sorting to function.

  5. Hi everybody.
    I’ve rails 2.4.3 and isntalled active scaffold, and had all the troubles that were listed above.
    Since now, i have only 2 problemas that can’t get them to work.
    i have a Bank model with an Agent model (agent has a bank_id column)
    when I try to edit, or to make a new Bank, i have the following error.

    Could not find ::AgentsController or ::AgentController

    I’ve already created AgentsController (scaffolding Agent)

    What could i have wrong?

  6. Thanks! This completely solved my problem with column sorting and searching not working with Rails 2.3.4. What a relief!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.