Skip to content

Instantly share code, notes, and snippets.

@glaville
Created August 26, 2010 13:47
Show Gist options
  • Save glaville/551403 to your computer and use it in GitHub Desktop.
Save glaville/551403 to your computer and use it in GitHub Desktop.
--- a/lib/scaffolding_extensions/controller/ramaze.rb 2010-08-26 06:18:19.000000000 +0200
+++ b/lib/scaffolding_extensions/controller/ramaze.rb 2010-08-26 15:44:50.379829006 +0200
@@ -94,12 +94,30 @@
def scaffold_setup_helper
engine :Erubis
layout(:layout){|name, wish| !request.xhr? }
-
- o = app.options
- o.roots = [scaffold_template_dir]
- o.views = ['/']
- o.layouts = ['/']
-
+
+ # Instantiates the controller's App (necessary to have a valid
+ # Ramaze::Controller.options, which is actually just a shortcut
+ # to controller's App options)
+ self.setup
+
+ # Retrieves current controller options, and ensure the required ones
+ # are properly initialized
+ o = self.options
+ o.roots ||= []
+ o.views ||= []
+ o.layouts ||= []
+
+ # Adds scaffold_template_dir to the controller roots
+ unless o.roots.include?(scaffold_template_dir)
+ o.roots = [*o.roots, scaffold_template_dir]
+ end
+
+ # The scaffolding_extensions templates are located directly in the
+ # scaffold_template_dir, not in a view/ or layout/ subdirectory,
+ # so adds '/' to the views et layout default search paths
+ o.views << '/' unless o.views.include? '/'
+ o.layouts << '/' unless o.layouts.include? '/'
+
include ScaffoldingExtensions::Controller
include ScaffoldingExtensions::RamazeController
include ScaffoldingExtensions::Helper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment