A have a base controller for my admin namespace
class Admin::AdminController < ApplicationController
def update
entity = @source.find(params[:id])
close_popup entity.update_attributes(params[@param_name])? {return_url => @url}:{}
end
...
end
And all my admin controllers derives from AdminController, eg:
class Admin::ProductsController < Admin::AdminController
@source = Admin::Product
@url = admin_products_url
@param_name = :admin_product
end
Now, my question is how can i avoid setting those parameters in the derrived classes. For that i will need to know from the base controller itself
- What scaffold is it associeted with. ( @source )
- The url for listing entities ( @url )
- Parameter name coming from POST associated to the entity ( @param_name)
Thanks
Well if you are sure that all these controllers will be in the format you mentioned, you could do the following:
define a
before_filterin theclass Admin::AdminControllernamedset_default_parmasreferences to used methods:
singularize, constantize, camelize and controller_name