views:

179

answers:

1

Hi All,

I have a 3yr old application that has some controllers with some very unrestful actions. I'm trying to implement a new resource that has relationships to some of the older ones, but I want to use activescaffold to manage the nested resources rather than try to rewrite the plate of spaghetti that is the rest of the codebase. I need to write new controllers for the nested resources that use activescaffold, but I can't lose the old controllers, and I can't rename them either. how can I get the activescaffold config to pick up the config for the nested resources from the new controller rather than trying to look at the conventionally named controller for the configuration?

thx for your help :)

-C

+2  A: 

You can use the active_scaffold_controller_for override method. From the ActiveScaffold documentation - http://www.activescaffold.com/docs/api-core

class ApplicationController < ActionController::base

  protected

  def self.active_scaffold_controller_for(klass)
    return FooController if klass == Bar
    return "#{klass}ScaffoldController".constantize rescue super
  end
end
Vertis
awesome, thx! I suppose I could even create controllers dynamically here, which might be a good way to go. thx again :)
Chris Drappier
this makes me ask another question, what should I check to determine if a controller has as?
Chris Drappier