[Rails] scaffold_path

Sascha Ebach se at digitale-wertschoepfung.de
Tue Nov 23 12:56:31 GMT 2004


Sean O'Halpin wrote:
> Thanks Sascha - I should have been clearer as to what exactly I was 
> looking for.
> 
> I was wondering if there were an ~easy~ way to override scaffold_path 
> without
> having to change library code or override the whole definition of scaffold.
> Because the scaffold method adds these methods dynamically to the 
> controller, you can't
> simply override only the scaffold_path method anywhere (it seems)
> as the act of adding the scaffold will redefine whatever method
> you put in place (it does a module_eval inside your controller).
> 
> So it appears that the only way to change the default scaffold_path is 
> to either:
> 
> 1) redefine the library definition (which will change the default path 
> for the whole installation!),

Indeed, not so good.

> 2) change it on a controller by controller basis by redefining the 
> scaffold_path after calling scaffold, e.g.
> 
>  scaffold :post
>  def scaffold_path "/web/app/scaffold/templates" end
> 
> or
> 3) override the whole scaffold definition
> 
> I'll probably go for 3).
> 
> I was just wondering if there were an easier way I was missing.

Have you tried overriding scaffold_path in 
AbstractApplicationController? If you want to change the path (or any 
setting that is) *per* application, than this should be the prefered way.

-- 
Sascha Ebach


More information about the Rails mailing list