<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>doc/advanced.txt</filename>
    </added>
    <added>
      <filename>doc/controller_spec.txt</filename>
    </added>
    <added>
      <filename>doc/conversion.txt</filename>
    </added>
    <added>
      <filename>doc/model_spec.txt</filename>
    </added>
    <added>
      <filename>doc/ramaze.txt</filename>
    </added>
    <added>
      <filename>doc/testing.txt</filename>
    </added>
    <added>
      <filename>lib/scaffolding_extensions/controller.rb</filename>
    </added>
    <added>
      <filename>lib/scaffolding_extensions/controller/action_controller.rb</filename>
    </added>
    <added>
      <filename>lib/scaffolding_extensions/controller/ramaze.rb</filename>
    </added>
    <added>
      <filename>lib/scaffolding_extensions/helper.rb</filename>
    </added>
    <added>
      <filename>lib/scaffolding_extensions/meta_controller.rb</filename>
    </added>
    <added>
      <filename>lib/scaffolding_extensions/model/active_record.rb</filename>
    </added>
    <added>
      <filename>lib/scaffolding_extensions/prototype_helper.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,4 @@
-Copyright (c) 2004-2007 Jeremy Evans
+Copyright (c) 2004-2008 Jeremy Evans
 
 Permission is hereby granted, free of charge, to any person obtaining a copy 
 of this software and associated documentation files (the &quot;Software&quot;), to deal</diff>
      <filename>LICENSE</filename>
    </modified>
    <modified>
      <diff>@@ -1,117 +1,94 @@
-ScaffoldingExtensions
-=====================
+= ScaffoldingExtensions
 
-The Scaffolding Extensions plugin enhances Rails' default scaffolding in the
-following ways:
+Scaffolding Extensions provides a powerful and simple to use administrative
+interface to perform common actions on models.  It has the following features:
 
-  * Choose which fields are displayed in the scaffolds and in which order
-  * Handle belongs_to associations with select boxes or auto completing text
-    boxes in the scaffolded forms
-  * Handle has_and_belongs_to_many associations, with multiple methods (Ajax,
-    select boxes, autocompleting text boxes)
-  * Show associated objects on the show and edit scaffolds
-  * Add links to associated objects on the edit scaffold for the model, 
-    allowing fast access to manage associated models, edit the 
-    has_and_belongs_to_many asociations, or add objects for has_many
-    associations.
-  * Add search scaffolding using any fields of the model, with a pagination of
-    the results
-  * Add scaffolding for merging records (combining two records into one by
-    updating all associations)
-  * Show associated data instead of the foreign key integer in show/search
-    results scaffold
-  * Specify the visible names for column headers and form labels
-  * Choose which methods are added by the scaffold function
-  * Many customization options for all parts of scaffolding
+* Creates pages for browsing, creating, deleting, displaying, updating, 
+  searching, and merging records
+* Choose which fields are displayed in the scaffolds and in which order
+* Handles associated records for common one-to-many, many-to-one, and
+  many-to-many associations.
+* Extensive support for modifying the display and working of the plugin
+* Advanced features such as access control, autocompleting, and eager loading
 
-Please note that this does not affect the scaffold generator (script/generate
-scaffold). This plugin only affects the scaffold method.  It is designed to
-replace the generator by being customizable enough so that you would not need
-to modify its output.  However, there is support for outputing the controller
-code generated by the scaffold method (see below).
+Scaffolding Extensions is not a code generator, and isn't really scaffolding at
+all, as you are not expected to modify the output.  Instead, you use
+configuration options inside the model to control the display of the pages.
+The scaffolding analogy is misleading, Scaffolding Extensions is not really
+scaffolding--it is a completely functional structure that you can easily modify
+to better suit your needs.
 
-This plugin should be compatible with Rails 2.0. Older versions are compatible
-with Rails 1.2.x (svn revision 81) and  Rails 1.1.x (svn revision 61), but the
-current version may not be. It is not tested on Edge Rails, it always targets
-the latest stable Rails version.
+The current version of Scaffolding Extensions is quite different from previous
+versions (svn revision 89 and previous).  For upgrading from an older version,
+see the conversion.txt file.
 
-svn: svn://code.jeremyevans.net/rails/plugins/scaffolding_extensions
-file: http://code.jeremyevans.net/code/scaffolding_extensions.tar.gz
-RDoc: http://code.jeremyevans.net/doc/scaffolding_extensions
+Scaffolding Extensions currently supports Rails 2.0 and Ramaze 0.3.5 web 
+frameworks.  It supports the ActiveRecord ORM.  Support for other web
+frameworks and ORMs can be added, see the controller_spec.txt and
+model_spec.txt files for the methods that need to be defined.
 
-Quick Start
-===========
+Older versions of Rails should be able to use an older version of the plugin,
+which won't be discussed further as it is substantially different from the
+current version (see the conversion.txt file for details).
 
-In an existing Rails application, create a controller
-(i.e. &quot;script/generate controller crud&quot;), and modify so it looks like:
+You can get Scaffolding Extensions via subversion or as a tarball:
 
-  class CrudController &lt; ApplicationController
-    scaffold_all_models
-  end
+* svn: svn://code.jeremyevans.net/rails-plugins/scaffolding_extensions
+* file: http://code.jeremyevans.net/code/scaffolding_extensions.tar.gz
+* RDoc: http://code.jeremyevans.net/doc/scaffolding_extensions
+
+== Quick Start
 
-Then go to the index page for the controller (e.g. http://website/crud).  
+The recommended use of the plugin is to execute:
+
+  scaffold_all_models
+  
+inside of a controller.  We'll assume the path to the controller is /admin.
+
+Then go to the index page for the controller (e.g. http://website/admin).  
 You'll see a link to a management page for each of your models.  Each
-management page has links to create, delete, edit, show, search, and merge
-pages for the model. The pages should be usable right away, but you'll want to
+management page has links to browse, create, delete, edit, show, search, and
+merge pages for the model. The pages are usable right away, but you'll want to
 add some configuration code to your models to specify the default names to
 display in select boxes, attributes to show on the forms, associations to show,
 whether to use select boxes or autocompleting text boxes, etc..
 
-Backwards Compatibility Note
-============================
-
-Recent versions of the plugin are more strict than previous versions in the 
-arguments to scaffold and scaffold_habtm. Originally I thought that using 
-singularize on an already singular word (or pluralize on an already plural
-word) would have no effect (like using camelize on an already camelized word).
-However, this isn't the case and can cause bugs for some common words (notably
-things ending in &quot;ss&quot;), so now you must you the singular, underscored, form:
-
-  scaffold :artist # Works
-  scaffold :albums # Doesn't work
+== Customization
 
-  scaffold :album, :habtm=&gt;:artist # Yes
-  scaffold :artist, :habtm=&gt;albums # No
-
-  scaffold_habtm :album, :artist # Dice
-  scaffold_habtm :albums, :artists # No Dice
-  scaffold_habtm :album, :artists # Still No Dice
-                                               
-I chose to use the singular form even for the habtm forms as that is the one
-the documentation has always used. Note that if you just use
-scaffold_all_models, you don't need to worry about this.
-
-Customization
-=============
-
-An addition to the new scaffold features that this plugin adds (merge, search,
-belongs_to, and habtm scaffolding), the major attraction of this plugin is the
-ability to customize the scaffolding by adding some code to the model class.
-Let's start with the most common customizations:
+The main reason to use this plugin are the features and extent of customization
+it provides.  Customization is done by adding methods and instance variables
+to the model class itself. Here are some common customizations:
 
   class Album &lt; ActiveRecord::Base
     has_and_belongs_to_many :artists
     belongs_to :genre
-    @scaffold_fields = %w'name rating genre numtracks'
+    @scaffold_fields = [:name, :rating, :genre, :numtracks]
     @scaffold_select_order = 'name'
     @scaffold_column_names = {:numtracks=&gt;'Number of Tracks'}
-    @scaffold_auto_complete_options = {}
+    @scaffold_use_auto_complete = true
     def scaffold_name
       name[0...50]
     end
   end
 
 @scaffold_fields determines which fields are shown in the new, edit, and search
-forms (which use the order specified).  It defaults to content_columns plus
-belongs_to associations. @scaffold_select_order determines which order is used
-in the SQL ORDER clause when displaying a list of albums (for example, from the
-edit link of the management page).  @scaffold_column_names specifies the 
-visible names for each attribute.  @scaffold_auto_complete_options turns on
-autocompleting for the model, instead of using select boxes (necessary for a
-decent response time if you have a large number of records).   scaffold_name
-determines the name to use for each album inside those select boxes.  Note that
-it is a method and not a variable, so you need to specify a ruby instance
-method for it.
+forms (which use the order specified).  It should be a list of symbols.  If you
+want some pages to show more fields than others, you can define variables such
+as @scaffold_edit_fields or @scaffold_search_fields to override the defaults
+for certain pages.
+
+@scaffold_select_order determines which order is used in the SQL ORDER BY
+clause when displaying a list of objects (for example, when choosing an object
+to edit).
+
+@scaffold_column_names specifies the visible names for each attribute.
+
+@scaffold_use_auto_complete turns on autocompleting for the model, instead
+of using select boxes (necessary for a decent response time if you have a large
+number of records). See the advanced.txt for more autocompleting options.
+
+scaffold_name is an instance method that determines the name to use for each
+album inside those select boxes.
 
 Notice in this case that genre was specified.  In this case, our schema has 
 genre_id as a foreign key to the genres table.  If you specified genre_id,
@@ -119,156 +96,48 @@ you'd get a usual text input box for the foreign key integer.  If you specify
 genre (the name of the belongs_to association), instead of a text input box,
 you will get a select box with all genres, allowing you to pick one.  It will
 use the @scaffold_select_order variable and scaffold_name method in the Genre 
-model to format the select box.  If you have @scaffold_auto_complete_options
-set in the Genre model, there will be an autocompleting text box instead of a
-select box (though since there aren't that many genres, you would probably be
-better off with a select box in this case).
-
-There are also a couple of customizations that can be set in the controller:
-
-  * @scaffold_template_dir =&gt; Allows you to choose a separate directory for the
-    scaffolds (instead of the one that comes with this plugin)
-  * @default_scaffold_methods =&gt; Allows you to change the methods scaffolded by
-    default, instead of using :except or :only each time.
-
-There are some other lessor used options which allow you to:
-
-  * Set the css class of scaffolded tables per ActiveRecord class
-  * Override the input widget type and widget options per attribute
-  * Choose which associations to display on the edit screen of a model
-  * Choose which associations to eagerly load when displaying select boxes for
-    the model
-  * Set the number of records returned in searching or browsing
-  * Specify different fields used in each type of scaffold (e.g. certain fields
-    can only be viewed, not edited)
-
-Consult the RDoc if you would like more information on these (and other
-options).
-
-General Usage
-=============
-
-In many cases, if you are just using the plugin to create an easy
-administrative front end to your existing application, it will probably be
-easier to use scaffold_all_models instead of following the instructions below,
-as that takes care of things for you.  The instructions below predate the
-introduction of scaffold_all_models, and show how different options passed to
-the scaffold method affect the creation of the scaffolding.  They will mainly
-be useful if you are using the scaffolding for non administrative forms.
-
-Generally, the scaffolding extensions are used in same way as the normal
-scaffolding.  Inside a controller, add:
-
-  scaffold :album
-  
-In addition to the normal options, this plugin adds the following options to
-the scaffold method:
-
-  * :except =&gt; don't generate methods for certain actions
-  * :only =&gt; only generate methods for given actions
-  * :habtm =&gt; generate a has_and_belongs_to_many scaffold for the given classes
-  * :generate =&gt; return the code generated instead of evaluating it
-
-So these is are valid calls to scaffold:
-
-  scaffold :album, :suffix=&gt;true, :except=&gt;:delete, :habtm=&gt;[:artist]
-  scaffold :artist, :only=&gt;[:new, :edit, :search, :manage], :habtm=&gt;:album
-
-Let's say you just do the simplest possible command (scaffold :album).  Then
-you go to the index of the controller.  You'll notice some differences.  The
-default Rails scaffold page has a paginated table of records.  This plugin
-changes that to a simple management page with the following links:
-
-  * Browse albums
-  * Create album
-  * Destroy album
-  * Edit album
-  * Merge albums
-  * Search albums
-  * Show album
-
-Clicking on show, destroy, or edit links will bring up a simple select box
-allowing you to choose a record to show, destroy, or edit.  Clicking on new
-will bring you to a form that allows you to create a new object (similar to the
-default form, with slightly different formatting).  Clicking on search will
-bring up a simple search form for searching on any of the fields in the new or
-edit form (the search results page looks similar to the default Rails list
-page).  Clicking on merge will bring up a page with two select boxes, allowing
-you to merge two records of the same type (by updating the necessary
-associations and then deleting the record to be merged).  Clicking on browse
-brings up a paginated table of records similar to the search results.
-
-If you specified any actions in :except (or didn't include them in :only),
-the appropriate links won't appear in the management page.  If you specified
-:manage in :except, the management page won't be created.  The scaffold methods
-that are available for use in :except and :only are:
-
-  [:manage, :show, :destroy, :edit, :new, :search, :merge, :browse]
-  
-Let's say you used the command:
-
-  scaffold :artist, :only=&gt;[:new, :edit, :search, :manage], :habtm=&gt;:album
-
-The manage page would look like:
-
-  * Create album
-  * Edit album
-  * Search albums
-
-If you click on the edit albums link and select an album, you'll notice that
-below the entry form for updating the album are all of the items associated
-with the current item (unless you overrode it using the
-@scaffolded_associations variable in the model).  Assuming you use 
-:suffix=&gt;true when creating scaffolds and create scaffolds for multiple models
-in the same controller, the associated items will be linked so that they can be
-easily edited.
-
-If you just want to create habtm scaffolds, there is a command that does so:
-
-  scaffold_habtm(:artist, :album)
-
-By default, this will create the habtm scaffold both ways. You can go to
-edit_album_artists/42 to edit the artists for album 42 and
-edit_artist_albums/42 to edit the albums for artist 42.
-
-Testing
-=======
-
-The plugin now includes functions that make it easier to test.  The testing 
-isn't comprehensive, as it doesn't test if the forms work, it just tests to see
-if you can successfully request the displayed pages.  Still, it is useful to
-see if any errors are produced due to naming conflicts (which can be resolved
-by adding some configuration code to the model or changing the arguments to the
-scaffold method call). For example:
-
-  class CrudControllerTest &lt; Test::Unit::TestCase
+model to format the select box (though this can be overridden with the
+@scaffold_genre_select_order_association variable in the Album model).
+
+If you have @scaffold_auto_complete_options set in the Genre model (or
+@scaffold_genre_association_use_auto_complete set in the Album model), there
+will be an autocompleting text box instead of a select box (though since there
+aren't that many genres, you would probably be better off with a select box in
+this case).
+
+There are a ton of other customization options:
+
+* Override the input widget type and widget options per attribute
+* Choose which associations to display on the edit screen of a model
+* Choose which associations to eagerly load when displaying select boxes for
+  the model
+* Set the number of records returned in searching or browsing
+* Specify different fields used in each type of scaffold (e.g. certain fields
+  can only be viewed, not edited)
+* Control access to the model via a session variable (e.g. so a user can only
+  see objects with a matching user_id)
+
+Consult advanced.txt and/or the RDoc if you would like more information on
+these (and many other options).
+
+== Testing (Rails only)
+
+The plugin includes functions that make it easier to test.  The testing isn't
+comprehensive, as it doesn't test if the forms work, it just tests to see if
+you can successfully request the displayed pages.  Still, it is useful to see
+if any errors are produced errors in the model configuration code (e.g. an
+invalid  @scaffold_select_order). For example:
+
+  class AdminControllerTest &lt; Test::Unit::TestCase
     def setup
-      @controller = CrudController.new
+      @controller = AdminController.new
       @request    = ActionController::TestRequest.new
       @response   = ActionController::TestResponse.new
    end
     test_scaffold_all_models
-    # or test_scaffold :album
   end
 
-Consult the RDoc if you want view more testing options.
-
-Code Generation
-===============
-
-I don't recommend using the generated code for anything more than debugging,
-but if you want to see the code that is generated, try this for a single model:
-
-  script/runner &quot;puts ActionController::Base.scaffold(:model, \
-                 :generate=&gt;true)&quot;
-
-or this for all models:
-
-  script/runner &quot;puts ActionController::Base.scaffold_all_models( \
-                 :generate=&gt;true)}&quot;
-
-Questions?
-==========
+== Questions?
 
 Feel free to contact me at code@jeremyevans.net if you have any questions
-about this plugin.
+about Scaffolding Extensions.</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -1,22 +1,12 @@
 require 'rake'
-require 'rake/testtask'
 require 'rake/rdoctask'
 
-desc 'Default: run unit tests.'
-task :default =&gt; :test
-
-desc 'Test the scaffolding_extensions plugin.'
-Rake::TestTask.new(:test) do |t|
-  t.libs &lt;&lt; 'lib'
-  t.pattern = 'test/**/*_test.rb'
-  t.verbose = true
-end
+desc 'Default: create rdoc.'
+task :default =&gt; :rdoc
 
 desc 'Generate documentation for the scaffolding_extensions plugin.'
 Rake::RDocTask.new(:rdoc) do |rdoc|
   rdoc.rdoc_dir = 'rdoc'
-  rdoc.title    = 'ScaffoldingExtensions'
-  rdoc.options &lt;&lt; '--line-numbers' &lt;&lt; '--inline-source'
-  rdoc.rdoc_files.include('README')
-  rdoc.rdoc_files.include('lib/**/*.rb')
+  rdoc.title    = 'Scaffolding Extensions'
+  %w'--line-numbers --inline-source -a README lib'.each{|x| rdoc.options &lt;&lt; x}
 end</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,9 @@
 This allows you to change the scaffolded display of associated items in the
 edit view from a simple list to a explorer-style clickable tree.
 
-To use this, add the .js file to public/javascripts, the .css file to 
-public/stylesheets, the .gif files to public/images and add the following code
-to the head section of the layout:
+To use this, include the .gifs in the /images subdirectory (or modify the .css
+file), and add the .css and .js files to the layout.
 
-  &lt;%= stylesheet_link_tag 'scaffold_associations_tree' %&gt;
-  &lt;%= javascript_include_tag 'scaffold_associations_tree' %&gt;
-  
-Then add this to environment.rb:
-
-  ActiveRecord::Base.scaffold_association_list_class = 'scaffold_associations_tree'
+Then set this in your application's environment:
 
+  ActiveRecord::Base::SCAFFOLD_OPTIONS[:association_list_class] = 'scaffold_associations_tree'</diff>
      <filename>contrib/scaffold_associations_tree/README</filename>
    </modified>
    <modified>
      <diff>@@ -2,11 +2,7 @@ This allows you to skip the output of the style when using scaffold auto
 completing.  This is necessary if you want to be XHTML compliant, as style tags
 aren't allowed inside form elements.
 
-To use this, add the .css file to public/stylesheets and add the following code
-to the head section of the layout:
+To use this, add the .css file to your layout. Then set this in your
+application's environment:
 
-  &lt;%= stylesheet_link_tag 'auto_complete' %&gt;
-  
-Then add this to environment.rb:
-
-  ActiveRecord::Base.scaffold_auto_complete_default_options.merge!({:skip_style=&gt;true})
+  ScaffoldingExtensions.auto_complete_skip_style = true</diff>
      <filename>contrib/scaffold_auto_complete_style/README</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,12 @@
 This allows you to auto focus the page to the first form field.
 
-To use this, add the .js file to public/javascripts, and modify the layout to
-include the javascript file after the scaffolded form:
+To use this, conditionally include the .js file in your layout via something
+like:
 
-  &lt;%= javascript_include_tag('scaffold_form_focus') if @scaffold_class || @scaffold_update_page %&gt;
+  &lt;%= javascript_include_tag('scaffold_form_focus') if @scaffold_options %&gt;
 
-The if statement makes it take effect for the scaffolded pages (which define
-one of the two variables).  Note that the code is fairly simplistic, it just
+The if statement makes it take effect for the scaffolded pages (which always
+define @scaffold_options).  Note that the code is fairly simplistic, it just
 focuses on the first text input, password input, textarea, or
 select box on the page, so if your layout has a form before the scaffolded
-form, you'll probably want to modify the code.  
+form, you'll probably want to modify the code.</diff>
      <filename>contrib/scaffold_form_focus/README</filename>
    </modified>
    <modified>
      <diff>@@ -1,1319 +1,70 @@
-# Scaffolding Extensions
 require 'set'
 
-module ActiveRecord # :nodoc:
-  # Modifying class variables allows you to set various defaults for scaffolding. 
-  # Note that if multiple subclasses each modify the class variables, chaos will ensue.
-  # Class variables have cattr_accessor so that you can set them in environment.rb, such as:
-  # ActiveRecord::Base.scaffold_convert_text_to_string = true
-  #
-  # Available class variables:
-  # - scaffold_convert_text_to_string: If true, by default, use input type text instead of textarea 
-  #   for fields of type text (default: false)
-  # - scaffold_table_classes: Set the default table classes for different scaffolded HTML tables
-  #   (default: {:form=&gt;'formtable', :list=&gt;'sortable', :show=&gt;'sortable'})
-  # - scaffold_column_types: Override the default column type for a given attribute 
-  #   (default: {'password'=&gt;:password})
-  # - scaffold_column_options_hash: Override the default column options for a given attribute (default: {})
-  # - scaffold_default_column_names: Override the visible names of columns for each attribute (default: {})
-  # - scaffold_association_list_class: Override the html class for the association list in the edit view
-  #   (default: '')
-  # - scaffold_browse_default_records_per_page - The default number of records per page to show in the
-  #   browse scaffold (default: 10)
-  # - scaffold_search_results_default_limit - The default limit on scaffolded search results.  If nil,
-  #   the search results will be displayed on one page instead of being paginated (default: 10)
-  # - scaffold_habtm_with_ajax_default - Whether or not to use Ajax (instead of a separate page) for 
-  #   habtm associations for all models (default: false)
-  # - scaffold_load_associations_with_ajax_default - Whether or not to use Ajax to load the display of
-  #   associations on the edit page, used if the default display is too slow (default: false)
-  # - scaffold_auto_complete_default_options: Hash containing the default options to use for the scaffold
-  #   autocompleter (default: {:enable=&gt;false, :sql_name=&gt;'LOWER(name)', :text_field_options=&gt;{:size=&gt;50},
-  #   :format_string=&gt;:substring, :search_operator=&gt;'LIKE', :results_limit=&gt;10, :phrase_modifier=&gt;:downcase,
-  #   :skip_style=&gt;false})
-  #
-  # Modifying instance variables in each class affects scaffolding for that class only.
-  # Available instance variables:
-  #
-  # - scaffold_fields: List of field names to include in the scaffolded forms.
-  #   Values in the list should be either actual fields names, or names of belongs_to
-  #   associations (in which case select boxes will be used in the scaffolded forms).
-  #   Uses content_columns + belongs_to associations if not specified.
-  #   (example: %w'name number rating')
-  # - scaffold_(new|edit|show|search|browse)_fields: Different scaffold actions can have different
-  #   fields displayed.  Defaults to scaffold_fields if not specified.
-  # - scaffold_select_order: SQL fragment string setting the order in which scaffolded records are shown
-  #   (example: 'firstname, lastname')
-  # - scaffold_include: Any associations that should be included by default when displaying the
-  #   scaffold name.  Eager loading is used so that N+1 queries aren't used for displaying N
-  #   records, assuming that associated records used in scaffold_name are included in this.
-  #   (example: [:artist, :album])
-  # - scaffold_(search|browse)_(select_order|include): Search and browse can have their own
-  #   select order and include.  For select order, defaults to scaffold_select_order if not given.
-  #   For include, defaults to the subset of scaffold_(search|browse)_fields that are 
-  #   associations instead of attributes.
-  # - scaffold_column_names: Override the visible names of columns for each attribute.
-  #   By default, this is just the humanized name. (example: {:modelnum=&gt;'Model Number'})
-  # - scaffold_associations: List of associations to display on the scaffolded edit page for the object.
-  #   Uses all associations if not specified (example: %w'artist albums')
-  # - scaffold_associations_path: String path to the template to use to render the associations
-  #   for the show/edit page.  Uses the controller's scaffold path if not specified.
-  #   (example: &quot;#{RAILS_ROOT}/lib/model_associations.rhtml&quot;)
-  # - scaffold_habtm_ajax_path: String path to the template to use to render the habtm ajax entries
-  #   for the edit page.  Uses the controller's scaffold path if not specified.
-  #   (example: &quot;#{RAILS_ROOT}/lib/model_habtm_ajax.rhtml&quot;)
-  # - scaffold_browse_records_per_page - The number of records per page to show in the
-  #   browse scaffold.  Uses scaffold_browse_default_records_per_page if not specified (example: 25)
-  # - scaffold_search_results_limit - The limit on the number of records in the scaffolded search
-  #   results page (example: 25)
-  # - scaffold_session_value - Use a value from the session to populate new values and control access
-  #    to current values (example: :user_id)
-  # - scaffold_habtm_with_ajax - Whether to use Ajax for habtm associations for this class (example: true)
-  # - scaffold_auto_complete_options - Hash merged with the auto complete default options to set
-  #   the auto complete options for the model.  If the auto complete default options are set
-  #   with :enable=&gt;false, setting this variable turns on autocompleting.  If the auto complete
-  #   default options are set with :enable=&gt;true, autocompleting can be turned off for this
-  #   model with {:enable=&gt;false}.  (example: {})
-  #
-  # scaffold_table_classes, scaffold_column_types, and scaffold_column_options_hash can also
-  # be specified as instance variables, in which case they will override the class variable
-  # defaults.
-  class Base
-    @@scaffold_convert_text_to_string = false
-    @@scaffold_table_classes = {:form=&gt;'formtable', :list=&gt;'sortable', :show=&gt;'sortable'}
-    @@scaffold_column_types = {'password'=&gt;:password}
-    @@scaffold_column_options_hash = {}
-    @@scaffold_association_list_class = ''
-    @@scaffold_default_column_names = {}
-    @@scaffold_browse_default_records_per_page = 10
-    @@scaffold_search_results_default_limit = 10
-    @@scaffold_habtm_with_ajax_default = false
-    @@scaffold_load_associations_with_ajax_default = false
-    @@scaffold_auto_complete_default_options = {:enable=&gt;false, :sql_name=&gt;'LOWER(name)',
-      :text_field_options=&gt;{:size=&gt;50}, :format_string=&gt;:substring, :search_operator=&gt;'LIKE',
-      :results_limit=&gt;10, :phrase_modifier=&gt;:downcase, :skip_style=&gt;false}
-    cattr_accessor :scaffold_convert_text_to_string, :scaffold_table_classes, :scaffold_column_types, :scaffold_column_options_hash, :scaffold_association_list_class, :scaffold_auto_complete_default_options, :scaffold_browse_default_records_per_page, :scaffold_search_results_default_limit, :scaffold_default_column_names, :scaffold_habtm_with_ajax_default, :scaffold_load_associations_with_ajax_default, :instance_writer =&gt; false
-    
-    class &lt;&lt; self
-      attr_accessor :scaffold_select_order, :scaffold_include, :scaffold_associations_path, :scaffold_habtm_ajax_path, :scaffold_session_value
-      
-      # Checks all files in the models directory to return strings for all models
-      # that are a subclass of the current class
-      def all_models
-        Dir[&quot;#{RAILS_ROOT}/app/models/*.rb&quot;].collect{|file|File.basename(file).sub(/\.rb$/, '')}.sort.reject{|model| (! model.camelize.constantize.ancestors.include?(self)) rescue true}
-      end
-      
-      # Merges the record with id from into the record with id to.  Updates all 
-      # associated records for the record with id from to be assocatiated with
-      # the record with id to instead, and then deletes the record with id from.
-      #
-      # Returns false if the ids given are the same.
-      def merge_records(from, to)
-        return false if from == to
-        transaction do
-          reflect_on_all_associations.each{|reflection| reflection_merge(reflection, from, to)}
-          destroy(from)
-        end
-        true
-      end
-      
-      def interpolate_conditions(conditions) # :nodoc:
-        return conditions unless conditions
-        aliased_table_name = table_name
-        instance_eval(&quot;%@#{conditions.gsub('@', '\@')}@&quot;)
-      end
-      
-      # Updates associated records for a given reflection and from record to point to the
-      # to record
-      def reflection_merge(reflection, from, to)
-        foreign_key = reflection.primary_key_name
-        sql = case reflection.macro
-          when :has_one, :has_many
-            return if reflection.options[:through]
-            &quot;UPDATE #{reflection.klass.table_name} SET #{foreign_key} = #{to} WHERE #{foreign_key} = #{from}#{&quot; AND #{reflection.options[:as]}_type = #{quote_value(name.to_s)}&quot; if reflection.options[:as]}\n&quot;
-          when :has_and_belongs_to_many
-            &quot;UPDATE #{reflection.options[:join_table]} SET #{foreign_key} = #{to} WHERE #{foreign_key} = #{from}\n&quot; 
-          else return
-        end
-        connection.update(sql)
-      end
-      
-      # List of strings for associations to display on the scaffolded edit page
-      def scaffold_associations
-        @scaffold_associations ||= reflect_on_all_associations.collect{|r|r.name.to_s unless (r.options.include?(:through) || r.options.include?(:polymorphic))}.compact.sort
-      end
-      
-      # Array of all habtm reflections for this model's scaffold_associations
-      def scaffold_habtm_reflections
-        @scaffold_habtm_reflections ||= (scaffold_associations.collect do |association|
-          reflection = reflect_on_association(association.to_sym)
-          reflection if reflection &amp;&amp; reflection.macro == :has_and_belongs_to_many
-        end).compact
-      end
-      
-      # Returns the list of fields to display on the scaffolded forms. Defaults
-      # to displaying all usually scaffolded columns with the addition of belongs
-      # to associations that aren't polymorphic.
-      #
-      # This the basis for the display of fields in the scaffolds.  Each type of scaffold
-      # that displays fields (new, edit, show, search, and browse), can have a different
-      # set of fields by overriding scaffold_*_fields (e.g. scaffold_new_fields) via a
-      # class method or class instance variable.
-      def scaffold_fields
-        return @scaffold_fields if @scaffold_fields
-        @scaffold_fields = columns.reject{|c| c.primary || c.name =~ /(\A(created|updated)_at|_count)\z/ || c.name == inheritance_column}.collect{|c| c.name}
-        reflect_on_all_associations.each do |reflection|
-          next if reflection.macro != :belongs_to || reflection.options.include?(:polymorphic)
-          @scaffold_fields.delete(reflection.primary_key_name)
-          @scaffold_fields.push(reflection.name.to_s)
-        end
-        @scaffold_fields.sort!
-        @scaffold_fields
-      end
-      
-      %w'new edit show search browse'.each do |type|
-        module_eval &lt;&lt;-&quot;end_eval&quot;, __FILE__, __LINE__
-          def scaffold_#{type}_fields
-            @scaffold_#{type}_fields ||= scaffold_fields
-          end
-          
-          def scaffold_#{type}_fields_replacing_associations
-            @scaffold_#{type}_fields_replacing_associations ||= scaffold_fields_replacing_associations(scaffold_#{type}_fields)
-          end
-        end_eval
-      end
-      
-      %w'search browse'.each do |type|
-        module_eval &lt;&lt;-&quot;end_eval&quot;, __FILE__, __LINE__
-          def scaffold_#{type}_select_order
-            @scaffold_#{type}_select_order ||= scaffold_select_order
-          end
-        end_eval
-      end
-      
-      # A list of symbols for including in the query for the search scaffold
-      def scaffold_search_include
-        @scaffold_search_include ||= scaffold_search_fields.collect{|field| field.to_sym if reflection = reflect_on_association(field.to_sym)}.compact
-      end
-      
-      # A list of symbols for including in the query for the browse scaffold
-      def scaffold_browse_include
-        @scaffold_browse_include ||= scaffold_browse_fields.collect{|field| field.to_sym if reflection = reflect_on_association(field.to_sym)}.compact
-      end
-      
-      # If search pagination is enabled (by default it is if 
-      # scaffold_search_results_limit is not nil)
-      def search_pagination_enabled?
-        !scaffold_search_results_limit.nil?
-      end
-      
-      # scaffold_fields with associations replaced by foreign key fields
-      def scaffold_fields_replacing_associations(fields = nil)
-        if fields.nil?
-          @scaffold_fields_replacing_associations ||= scaffold_fields_replacing_associations(scaffold_fields)
-        else
-          fields.collect do |field|
-            reflection = reflect_on_association(field.to_sym)
-            reflection ? reflection.primary_key_name : field
-          end
-        end
-      end
-      
-      # List of human visible names and field names to use for NULL/NOT NULL fields on the scaffolded search page
-      def scaffold_search_null_options
-        @scaffold_search_null_options ||= scaffold_search_fields_replacing_associations.collect do |field|
-          [scaffold_column_name(field), field] if columns_hash[field]
-        end.compact
-      end
-      
-      # Returns the scaffolded table class for a given scaffold type.
-      def scaffold_table_class(type)
-        @scaffold_table_classes ||= scaffold_table_classes
-        @scaffold_table_classes[type]
-      end
-      
-      # Returns the column type for the given scaffolded column name.  First checks to see
-      # if a value has been overriden using a class or instance variable, otherwise uses
-      # the default column type.
-      def scaffold_column_type(column_name)
-        @scaffold_column_types ||= scaffold_column_types
-        if @scaffold_column_types[column_name]
-          @scaffold_column_types[column_name]
-        elsif columns_hash.include?(column_name)
-          type = columns_hash[column_name].type
-          (scaffold_convert_text_to_string and type == :text) ? :string : type
-        end
-      end
-      
-      # Returns any special options for a given attribute
-      def scaffold_column_options(column_name)
-        @scaffold_column_options_hash ||= scaffold_column_options_hash
-        @scaffold_column_options_hash[column_name]
-      end
-      
-      # Returns the visable name for a given attribute
-      def scaffold_column_name(column_name)
-        @scaffold_column_names ||= scaffold_default_column_names
-        @scaffold_column_names[column_name.to_sym] || column_name.to_s.humanize
-      end
-      
-      # The number of records to show on each page when using the browse scaffold
-      def scaffold_browse_records_per_page
-        @scaffold_browse_records_per_page ||= scaffold_browse_default_records_per_page
-      end
-      
-      # The maximum number of results to show on the scaffolded search results page
-      def scaffold_search_results_limit
-        @scaffold_search_results_limit ||= scaffold_search_results_default_limit
-      end
-      
-      # Whether to use Ajax when scaffolding habtm associations for this model
-      def scaffold_habtm_with_ajax
-        @scaffold_habtm_with_ajax ||= scaffold_habtm_with_ajax_default
-      end
-      
-      # Whether to use Ajax when loading associations on the edit page
-      def scaffold_load_associations_with_ajax
-        @scaffold_load_associations_with_ajax ||= scaffold_load_associations_with_ajax_default
-      end
-      
-      # If the auto complete options have been setup, return them.  Otherwise,
-      # create the auto complete options using the defaults and the existing
-      # class instance variable.
-      def scaffold_auto_complete_options
-        return @scaffold_auto_complete_options if @scaffold_auto_complete_options &amp;&amp; @scaffold_auto_complete_options[:setup]
-        @scaffold_auto_complete_options = @scaffold_auto_complete_options.nil? ? {} : {:enable=&gt;true}.merge(@scaffold_auto_complete_options)
-        @scaffold_auto_complete_options = scaffold_auto_complete_default_options.merge(@scaffold_auto_complete_options)
-        @scaffold_auto_complete_options[:setup] = true
-        @scaffold_auto_complete_options
-      end
-      
-      # Whether this class should use an autocompleting text box instead of a select
-      # box for choosing items.
-      def scaffold_use_auto_complete
-        scaffold_auto_complete_options[:enable]
-      end
-      
-      # SQL fragment (usually column name) that is used when scaffold autocompleting is turned on.
-      def scaffold_name_sql
-        scaffold_auto_complete_options[:sql_name]
-      end
-      
-      # Options for the scaffold autocompleting text field
-      def scaffold_auto_complete_text_field_options
-        scaffold_auto_complete_options[:text_field_options]
-      end
-      
-      # Don't use the style tags, used if they are already defined in the CSS file
-      def scaffold_auto_complete_skip_style
-        scaffold_auto_complete_options[:skip_style]
-      end
-      
-      # Format string used with the phrase to choose the type of search.  Can be
-      # a user defined format string or one of these special symbols:
-      # - :substring - Phase matches any substring of scaffold_name_sql
-      # - :starting - Phrase matches the start of scaffold_name_sql
-      # - :ending - Phrase matches the end of scaffold_name_sql
-      # - :exact - Phrase matches scaffold_name_sql exactly
-      def scaffold_auto_complete_search_format_string
-        {:substring=&gt;'%%%s%%', :starting=&gt;'%s%%', :ending=&gt;'%%%s', :exact=&gt;'%s'}[scaffold_auto_complete_options[:format_string]] || scaffold_auto_complete_options[:format_string]
-      end
-      
-      # Search operator for matching scaffold_name_sql to format_string % phrase,
-      # usally 'LIKE', but might be 'ILIKE' on some databases.
-      def scaffold_auto_complete_search_operator
-        scaffold_auto_complete_options[:search_operator]
-      end
-      
-      # The number of results to return for the scaffolded autocomplete text box.
-      def scaffold_auto_complete_results_limit
-        scaffold_auto_complete_options[:results_limit]
-      end
-      
-      # The conditions phrase (the sql code with ? place holders) used in the
-      # scaffolded autocomplete find.
-      def scaffold_auto_complete_conditions_phrase
-        scaffold_auto_complete_options[:conditions_phrase] ||= &quot;#{scaffold_name_sql} #{scaffold_auto_complete_search_operator} ?&quot;
-      end
-      
-      # A symbol for a string method to send to the submitted phrase.  Usually
-      # :downcase to preform a case insensitive search, but may be :to_s for
-      # a case sensitive search.
-      def scaffold_auto_complete_phrase_modifier
-        scaffold_auto_complete_options[:phrase_modifier]
-      end
-      
-      # The conditions to use for the scaffolded autocomplete find.
-      def scaffold_auto_complete_conditions(phrase, session_value = nil)
-        conditions = [scaffold_auto_complete_conditions_phrase, (scaffold_auto_complete_search_format_string % phrase.send(scaffold_auto_complete_phrase_modifier))]
-        if scaffold_session_value &amp;&amp; session_value
-          conditions[0] &lt;&lt; &quot; AND #{scaffold_session_value} = ?&quot;
-          conditions &lt;&lt; session_value
-        end
-        conditions
-      end
-      
-      # Return all records that match the given phrase (usually a substring of
-      # the most important column).
-      def scaffold_auto_complete_find(phrase, options = {})
-        find_options = { :limit =&gt; scaffold_auto_complete_results_limit,
-            :conditions =&gt; scaffold_auto_complete_conditions(phrase, options.delete(:session_value)), 
-            :order =&gt; scaffold_select_order,
-            :include =&gt; scaffold_include}.merge(options)
-        find(:all, find_options)
-      end
-    end
-    
-    # Merges the current record into the record given and returns the record given.
-    # Returns false if the record isn't the same class as the current class or
-    # if you try to merge a record into itself (which would be the same as deleting it).
-    def merge_into(record)
-      return false unless record.class == self.class &amp;&amp; self.class.merge_records(self, id, record.id)
-      record.reload
-    end
-    
-    # Only update the attributes given in allowed_fields
-    def update_scaffold_attributes(allowed_fields, new_attributes)
-      return if new_attributes.nil?
-      attributes = new_attributes.dup
-      attributes.stringify_keys!
-      attributes.delete_if{|k,v| !allowed_fields.include?(k.split('(')[0])}
-      
-      multi_parameter_attributes = []
-      attributes.each do |k, v|
-        k.include?(&quot;(&quot;) ? multi_parameter_attributes &lt;&lt; [ k, v ] : send(k + &quot;=&quot;, v)
-      end
-      
-      assign_multiparameter_attributes(multi_parameter_attributes)
-    end
-    
-    # The name given to the item that is used in various places in the scaffold.  For example,
-    # it is used whenever the record is displayed in a select box.  Should be unique for each record.
-    # Should be overridden by subclasses unless they have a unique attribute named 'name'.
-    def scaffold_name
-      self[:name] or id
-    end
+# This is the base module for the plugin.  It has some constants that can be
+# changed:
+#
+# * TEMPLATE_DIR - the directory with the scaffold templates
+# * DEFAULT_METHODS - the default methods added by the scaffolding
+#
+# If you include the contents of auto_complete.css in your stylesheet, set
+# &quot;auto_complete_skip_style = true&quot;, so the stylesheet isn't added for every
+# autocompleting text box.
+#
+# Scaffolding Extensions attempts to determine which framework/ORM you are
+# using and load the support for it (if it is supported).
+module ScaffoldingExtensions
+  AUTO_COMPLETE_CSS = &lt;&lt;-END
+    &lt;style type='text/css'&gt;
+      div.auto_complete {
+        width: 350px;
+        background: #fff;
+      }
+      div.auto_complete ul {
+        border:1px solid #888;
+        margin:0;
+        padding:0;
+        width:100%;
+        list-style-type:none;
+      }
+      div.auto_complete ul li {
+        margin:0;
+        padding:3px;
+      }
+      div.auto_complete ul li.selected { 
+        background-color: #ffb; 
+      }
+      div.auto_complete ul strong.highlight { 
+        color: #800; 
+        margin:0;
+        padding:0;
+      }
+    &lt;/style&gt;
+  END
+  ROOT = File.dirname(File.dirname(__FILE__))
+  TEMPLATE_DIR = File.join(ROOT, &quot;scaffolds&quot;)
+  DEFAULT_METHODS = [:manage, :show, :delete, :edit, :new, :search, :merge, :browse]
+  
+  @auto_complete_skip_style = false
     
-    # scaffold_name prefixed with id, used for scaffold autocompleting (a nice hack thanks 
-    # to String#to_i)
-    def scaffold_name_with_id
-      &quot;#{id} - #{scaffold_name}&quot;
-    end
-  end
-end
+  class &lt;&lt; self
+    attr_accessor :auto_complete_skip_style
+    attr_writer :all_models, :model_files
 
-module ActionView # :nodoc:
-  module Helpers # :nodoc:
-    # Changes the default scaffolding of new/edit forms to handle associated
-    # records, and uses a table to display the form.
-    module ActiveRecordHelper
-      # Takes record's scaffold_fields (or specified fields) and creates the 
-      # necessary form fields html fragment.  Uses a table by default so that
-      # everything lines up nicely.
-      def all_input_tags(record, record_name, options)
-        input_block = options[:input_block] || default_input_block
-        rows = (options[:fields] || record.class.scaffold_fields).collect do |field|
-          input_block.call(record_name, record.class.reflect_on_association(field.to_sym) || record.column_for_attribute(field) || field) 
-        end
-        all_input_tags_wrapper(record, rows)
-      end
-      
-      # Get label and widget for record_name and column
-      def input_tag_label_and_widget(record_name, column)
-          column_name = column.send(column.is_a?(String) || column.is_a?(Symbol) ? :to_s : :name)
-          label_id, tag = if column.class.name =~ /Reflection/
-            next unless column.macro == :belongs_to
-            [&quot;#{record_name}_#{column.primary_key_name}&quot;, association_select_tag(record_name, column_name)]
-          else
-            [&quot;#{record_name}_#{column_name}&quot;, input(record_name, column_name) || text_field(record_name, column_name)]
-          end
-          [&quot;&lt;label for='#{label_id}'&gt;#{@scaffold_class ? @scaffold_class.scaffold_column_name(column_name) :  column_name.to_s.humanize}&lt;/label&gt;&quot;, tag]
-      end
-        
-      # Wrap all input tags (table rows) in a table
-      def all_input_tags_wrapper(record, rows)
-        &quot;\n#{token_tag}\n&lt;table class='#{record.class.scaffold_table_class :form}'&gt;&lt;tbody&gt;\n#{rows.join}&lt;/tbody&gt;&lt;/table&gt;\n&quot;
-      end
-      
-      # Wrap label and widget in table row
-      def input_tag_wrapper(label, tag)
-          &quot;&lt;tr&gt;&lt;td&gt;#{label}&lt;/td&gt;&lt;td&gt;#{tag}&lt;/td&gt;&lt;/tr&gt;\n&quot;
-      end
-      
-      # Create html fragment for field for record_name and column
-      def default_input_block
-        Proc.new{|record_name, column| input_tag_wrapper(*input_tag_label_and_widget(record_name, column))}
-      end
-      
-      # Returns a select box displaying all possible records in the associated model
-      # that can be associated with this model.  If scaffold autocompleting is turned
-      # on for the associated model, uses an autocompleting text box. 
-      def association_select_tag(record, association)
-        reflection = record.camelize.constantize.reflect_on_association(association)
-        if reflection.klass.scaffold_use_auto_complete
-          scaffold_text_field_with_auto_complete(record, reflection.primary_key_name, reflection.klass.name.underscore)
-        else
-          conditions = reflection.klass.interpolate_conditions(reflection.options[:conditions])
-          if reflection.klass.scaffold_session_value
-            session_conditions = &quot;#{reflection.klass.table_name}.#{reflection.klass.scaffold_session_value} = #{session[reflection.klass.scaffold_session_value]}&quot;
-            conditions = conditions ? &quot;#{conditions} AND #{session_conditions}&quot; : session_conditions
-          end
-          items = reflection.klass.find(:all, :order =&gt; reflection.klass.scaffold_select_order, :conditions =&gt; conditions, :include=&gt;reflection.klass.scaffold_include)
-          select(record, reflection.primary_key_name, items.collect{|i| [i.scaffold_name, i.id]}, {:include_blank=&gt;true})
-        end
-      end
-      
-      # Returns a select box displaying the records for the associated model that
-      # are not already associated with this record.  If scaffold autocompleting is
-      # used, uses an autocompleting text box.
-      def association_ajax_select_tag(id, record, reflection)
-        if reflection.klass.scaffold_use_auto_complete
-          scaffold_text_field_tag_with_auto_complete(id, reflection.klass)
-        else
-          singular_class = record.class
-          foreign_key = reflection.primary_key_name
-          join_table = reflection.options[:join_table]
-          items = reflection.klass.find(:all, :order =&gt; reflection.klass.scaffold_select_order, :conditions =&gt;[&quot;#{reflection.klass.table_name}.#{reflection.klass.primary_key} NOT IN (SELECT #{reflection.association_foreign_key} FROM #{join_table} WHERE #{join_table}.#{foreign_key} = ?) #{&quot;AND #{reflection.klass.table_name}.#{reflection.klass.scaffold_session_value} = #{session[reflection.klass.scaffold_session_value]}&quot; if reflection.klass.scaffold_session_value}&quot;, record.id], :include=&gt;reflection.klass.scaffold_include)
-          select_tag(id, &quot;&lt;option&gt;&lt;/option&gt;&quot; &lt;&lt; items.collect{|item| &quot;&lt;option value='#{item.id}' id='#{id}_#{item.id}'&gt;#{h item.scaffold_name}&lt;/option&gt;&quot;}.join(&quot;\n&quot;))
-        end
-      end
-      
-      # Line item with button for removing the associated record from the current record
-      def scaffold_habtm_association_line_item(record, record_name, associated_record, associated_record_name)
-        &quot;&lt;li id='#{record_name}_#{record.id}_#{associated_record_name}_#{associated_record.id}'&gt;#{link_to_or_text(associated_record_name.humanize, :action=&gt;&quot;manage_#{associated_record.class.name.underscore}&quot;)} - #{link_to_or_text(h(associated_record.scaffold_name), :action=&gt;&quot;edit_#{associated_record.class.name.underscore}&quot;, :id=&gt;associated_record.id)} #{button_to_remote('Remove', :url=&gt;url_for(:action=&gt;&quot;remove_#{associated_record_name}_from_#{record_name}&quot;, :id=&gt;record.id, &quot;#{record_name}_#{associated_record_name}_id&quot;.to_sym=&gt;associated_record.id))}&lt;/li&gt;&quot;
-      end
-    end
-        
-    # Methods used to implement scaffold autocompleting
-    module ScaffoldAutoCompleteMacrosHelper
-      # Text field with autocompleting used for belongs_to associations of main object in scaffolded forms.
-      def scaffold_text_field_with_auto_complete(object, method, associated_class, tag_options = {})
-        klass = associated_class.to_s.camelize.constantize
-        foreign_key = instance_variable_get(&quot;@#{object}&quot;).send(method)
-        ((klass.scaffold_auto_complete_skip_style ? '' : auto_complete_stylesheet) +
-        text_field(object, method, klass.scaffold_auto_complete_text_field_options.merge({:value=&gt;(foreign_key ? klass.find(foreign_key).scaffold_name_with_id : '')}).merge(tag_options)) +
-        content_tag(&quot;div&quot;, &quot;&quot;, :id =&gt; &quot;#{object}_#{method}_scaffold_auto_complete&quot;, :class =&gt; &quot;auto_complete&quot;) +
-        scaffold_auto_complete_field(&quot;#{object}_#{method}&quot;, { :url =&gt; { :action =&gt; &quot;scaffold_auto_complete_for_#{associated_class}&quot; } }))
-      end
-      
-      # Text field with autocompleting for classes without an attached object.
-      def scaffold_text_field_tag_with_auto_complete(id, klass, tag_options = {})
-        ((klass.scaffold_auto_complete_skip_style ? '' : auto_complete_stylesheet) +
-        text_field_tag(id, nil, klass.scaffold_auto_complete_text_field_options.merge(tag_options)) +
-        content_tag(&quot;div&quot;, &quot;&quot;, :id =&gt; &quot;#{id}_scaffold_auto_complete&quot;, :class =&gt; &quot;auto_complete&quot;) +
-        scaffold_auto_complete_field(id, { :url =&gt; { :action =&gt; &quot;scaffold_auto_complete_for_#{klass.name.underscore}&quot;} }))
-      end
-      
-      # Javascript code for setting up autocomplete for given field_id
-      def scaffold_auto_complete_field(field_id, options = {})
-        javascript_tag(&quot;var #{field_id}_auto_completer = new Ajax.Autocompleter('#{field_id}', '#{options[:update] || &quot;#{field_id}_scaffold_auto_complete&quot;}', '#{url_for(options[:url])}', {paramName:'id', method:'get'})&quot;)
-      end
-      
-      # Formats the records returned by scaffold autocompleting to be displayed
-      # (an unordered list by default).
-      def scaffold_auto_complete_result(entries)
-        return unless entries
-        content_tag(&quot;ul&quot;, entries.map{|entry| content_tag(&quot;li&quot;, h(entry.scaffold_name_with_id))}.uniq)
-      end
-    end
-    
-    module PrototypeHelper
-      # Button that submits via Ajax, similar to link_to_remote
-      def button_to_remote(name, options = {})  
-        &quot;#{form_remote_tag(options)}&lt;input type='submit' value=#{name.inspect} /&gt;&lt;/form&gt;&quot;
-      end
-    end
-    
-    class InstanceTag
-      # Gets the default options for the attribute and merges them with the given options.
-      # Chooses an appropriate widget based on attribute's column type.
-      def to_tag(options = {})
-        options = (object.class.scaffold_column_options(@method_name) || {}).merge(options)
-        case column_type
-          when :string, :integer, :float
-            to_input_field_tag(&quot;text&quot;, options)
-          when :password
-            to_input_field_tag(&quot;password&quot;, options)
-          when :text
-            to_text_area_tag(options)
-          when :date
-            to_date_select_tag(options)
-          when :datetime
-            to_datetime_select_tag(options)
-          when :boolean
-            to_boolean_select_tag(options)
-          when :file
-            to_input_field_tag(&quot;file&quot;, options)
-        end
-      end
-      
-      # Returns three valued select widget, for null, false, and true, with the appropriate
-      # value selected
-      def to_boolean_select_tag(options = {})
-        options = options.stringify_keys
-        add_default_name_and_id(options)
-        &quot;&lt;select#{tag_options(options)}&gt;&lt;option value=''#{selected(value(object).nil?)}&gt;&amp;nbsp;&lt;/option&gt;&lt;option value='f'#{selected(value(object) == false)}&gt;False&lt;/option&gt;&lt;option value='t'#{selected(value(object))}&gt;True&lt;/option&gt;&lt;/select&gt;&quot;
-      end
-      
-      # Returns XHTML compliant fragment for whether the value is selected or not
-      def selected(value)
-        value ? &quot; selected='selected'&quot; : '' 
-      end
-      
-      # Allow overriding of the column type by asking the model for the appropriate column type.
-      def column_type
-        object.class.scaffold_column_type(@method_name)
-      end
+    # The stylesheet for the autocompleting text box, or the empty string
+    # if auto_complete_skip_style is true.
+    def auto_complete_css
+      auto_complete_skip_style ? '' : AUTO_COMPLETE_CSS
     end
   end
 end
 
-# Contains methods used by the scaffolded forms.
-module ScaffoldHelper
-  # Returns link if the controller will respond to the given action, otherwise returns the text itself.
-  # If :action is not specified in the options, returns link.
-  def link_to_or_text(name, options={}, html_options=nil, *parameters_for_method_reference)
-    link_to_or_plain_text(name, name, options, html_options, *parameters_for_method_reference)
-  end
-  
-  # Returns link if the controller will respond to the given action, otherwise returns &quot;&quot;.
-  # If :action is not specified in the options, returns link.
-  def link_to_or_blank(name, options={}, html_options=nil, *parameters_for_method_reference)
-    link_to_or_plain_text(name, '', options, html_options, *parameters_for_method_reference)
-  end
-  
-  # Returns link if the controller will respond to the given action, otherwise returns plain.
-  # If :action is not specified in the options, returns link.
-  def link_to_or_plain_text(name, plain, options={}, html_options=nil, *parameters_for_method_reference)
-    _controller = options[:controller] ? options[:controller].camelize.constantize : controller
-    if options[:action]
-      _controller.respond_to?(options[:action]) ? link_to(name, options, html_options, *parameters_for_method_reference) : plain
-    else link_to(name, options, html_options, *parameters_for_method_reference)
-    end
-  end
-  
-  # Returns html fragment containing information on related models and objects.
-  # The fragment will include links to scaffolded pages for the related items if the links would work.
-  def association_links
-    filename = (@scaffold_class.scaffold_associations_path || controller.scaffold_path(&quot;associations&quot;))
-    controller.send(:render_to_string, {:file=&gt;filename, :layout=&gt;false}) if File.file?(filename)
-  end
-  
-  # Returns html fragment containing text/select boxes to add associated records
-  # to the current record, and line items with buttons to remove associated records
-  # from the current record.
-  def habtm_ajax_associations
-    filename = (@scaffold_class.scaffold_habtm_ajax_path || controller.scaffold_path(&quot;habtm_ajax&quot;))
-    controller.send(:render_to_string, {:file=&gt;filename, :layout=&gt;false}) if File.file?(filename)
-  end
-  
-  # Returns link to the scaffolded management page for the model if it was created by the scaffolding.
-  def manage_link
-    &quot;&lt;br /&gt;#{link_to(&quot;Manage #{@scaffold_plural_name.humanize.downcase}&quot;, :action =&gt; &quot;manage#{@scaffold_suffix}&quot;)}&quot; if @scaffold_methods.include?(:manage)
-  end
-  
-  # Whether the form should be a multipart form (i.e. contains a file field)
-  def multipart?(column_names)
-    return false unless column_names
-    column_names.each { |column_name| return true if @scaffold_class.scaffold_column_type(column_name) == :file }
-    false
-  end
-  
-  # Returns an appropriate scaffolded data entry form for the model, with any related error messages.
-  def scaffold_form(action, options = {})
-    &quot;#{error_messages_for(@scaffold_singular_name)}\n#{form(@scaffold_singular_name, {:action=&gt;&quot;#{action}#{@scaffold_suffix}&quot;, :submit_value=&gt;&quot;#{action.capitalize} #{@scaffold_singular_name.humanize.downcase}&quot;, :multipart=&gt;multipart?(options[:fields])}.merge(options))}&quot;
-  end
-  
-  # Returns associated object's scaffold_name if column is an association, otherwise returns column value.
-  def scaffold_value(entry, column)
-    entry.send(column).methods.include?('scaffold_name') ? entry.send(column).scaffold_name : entry.send(column)
-  end
-end
+require 'scaffolding_extensions/controller'
+require 'scaffolding_extensions/meta_controller'
+require 'scaffolding_extensions/helper'
+require 'scaffolding_extensions/prototype_helper'
 
-module ActionController # :nodoc:
-  # Two variables can be set that affect scaffolding, either as class variables
-  # (which specifies the default for all classes) or instance variables (which
-  # specifies the values for that class only).
-  #
-  # - scaffold_template_dir: the location of the scaffold templates (default:
-  #   &quot;#{File.dirname(__FILE__)}/../scaffolds&quot; # the plugin's default scaffold directory)
-  # - default_scaffold_methods: the default methods added by the scaffold function
-  #   (default: [:manage, :show, :destroy, :edit, :new, :search, :merge, :browse] # all methods)
-  class Base
-    @@scaffold_template_dir = &quot;#{File.dirname(__FILE__)}/../scaffolds&quot;
-    @@default_scaffold_methods = [:manage, :show, :delete, :edit, :new, :search, :merge, :browse]
-    cattr_accessor :scaffold_template_dir, :default_scaffold_methods, :instance_writer =&gt; false
-    
-    helper ActionView::Helpers::ScaffoldAutoCompleteMacrosHelper
-    
-    # Returns path to the given scaffold rhtml file
-    def scaffold_path(template_name)
-      self.class.scaffold_path(template_name)
-    end
-    
-    # Return whether scaffolding provided the method, whether or not it was overwritten
-    def scaffolded_method?(method_name)
-      self.class.scaffolded_methods.include?(method_name)
-    end
-    
-    # Return whether scaffolding provided the method, if the method is nonidempotent
-    def scaffolded_nonidempotent_method?(method_name)
-      self.class.scaffolded_nonidempotent_methods.include?(method_name)
-    end
-    
-    private
-    # Redirect to the appropriate form for the scaffolded model
-    #
-    # In addition to scaffold_redirect, there is also uses scaffold_#{action}_redirect
-    # (e.g. scaffold_(new|edit|destroy|merge)_redirect), which makes the redirect modifiable per action.
-    # So if you to redirect to the edit page of an object just after creating it,
-    # you may want to redefine scaffold_new_redirect:
-    #
-    #  def scaffold_edit_redirect(suffix)
-    #    redirect_to({:action =&gt; &quot;edit#{suffix}&quot;, :id=&gt;params[:id].to_i})
-    #  end
-    #
-    # You can also define redirects for a given action and a model:
-    #
-    #  def scaffold_edit_artist_redirect
-    #    redirect_to({:controller=&gt;'artists', :action=&gt;&quot;profile&quot;, :id=&gt;params[:id].to_i})
-    #  end
-    def scaffold_redirect(action, suffix)
-      redirect_to({:action =&gt; &quot;#{action}#{suffix}&quot;, :id=&gt;nil})
-    end
-    
-    %w'delete edit new merge'.each do |action|
-      module_eval &lt;&lt;-&quot;end_eval&quot;, __FILE__, __LINE__
-        def scaffold_#{action}_redirect(suffix)
-          action = 'scaffold_#{action}\#{suffix}_redirect'
-          respond_to?(action) ? send(action) : scaffold_redirect(&quot;#{action}&quot;, suffix)
-        end
-      end_eval
-    end
-    
-    # Redirect to the appropriate page after a habtm associations update
-    #
-    # Because the habtm update form redirects even on failure, both the suffix
-    # and a success flag are passed.
-    #
-    # Like scaffold_redirect, it's possible to change the redirect per model, via:
-    #
-    #  def scaffold_habtm_artist_albums_redirect(suffix)
-    #    redirect_to({:controller=&gt;'artists', :action=&gt;&quot;profile&quot;, :id=&gt;params[:id].to_i})
-    #  end
-    #
-    def scaffold_habtm_redirect(suffix, success)
-      action = &quot;scaffold_habtm#{suffix}_redirect&quot;
-      respond_to?(action) ? send(action, success) : redirect_to(:action=&gt;&quot;edit#{suffix}&quot;, :id=&gt;params[:id].to_i)
-    end
+require 'scaffolding_extensions/controller/action_controller' if defined? ActionController::Base
+require 'scaffolding_extensions/controller/ramaze' if defined? Ramaze::Controller
 
-    def caller_method_name(caller) # :nodoc:
-      x = caller.first.scan(/`(.*)'/).first.first
-    end
-    
-    # Renders manually created page if it exists, otherwise renders a scaffold form.
-    # If a layout is specified (either in the controller or as an option), use that layout,
-    # otherwise uses the scaffolded layout.
-    def render_scaffold_template(action, options = {}) # :doc:
-      options = if template_exists?(&quot;#{self.class.controller_path}/#{action}&quot;)
-        {:action=&gt;action}.merge(options)
-      elsif options.include?(:inline)
-        options
-      else
-        if active_layout || options.include?(:layout)
-          {:file=&gt;scaffold_path(action.split('_')[0]), :layout=&gt;active_layout}.merge(options)
-        else
-          @content_for_layout = render_to_string({:file=&gt;scaffold_path(action.split('_')[0])}.merge(options))
-          {:file=&gt;scaffold_path(&quot;layout&quot;)}
-        end
-      end
-      render(options)
-    end
-    
-    # Converts all items in the array to integers and discards non-zero values
-    def multiple_select_ids(arr) # :doc:
-      arr = [arr] unless arr.is_a?(Array)
-      arr.collect{|x| x.to_i}.delete_if{|x| x == 0}
-    end
-    
-    # Adds conditions for the scaffolded search query.  Uses a search for string attributes,
-    # IS TRUE|FALSE for boolean attributes, and = for other attributes.
-    def scaffold_search_add_condition(conditions, record, field) # :doc:
-      return unless column = record.column_for_attribute(field)
-      if column.klass == String
-        if record.send(field).length &gt; 0
-          conditions[0] &lt;&lt; &quot;#{record.class.table_name}.#{field} #{record.class.scaffold_auto_complete_search_operator} ?&quot;
-          conditions &lt;&lt; &quot;%#{record.send(field)}%&quot;
-        end
-      elsif column.klass == Object
-        conditions[0] &lt;&lt; &quot;#{record.class.table_name}.#{field} IS #{record.send(field) ? 'TRUE' : 'FALSE'}&quot;
-      else
-        conditions[0] &lt;&lt; &quot;#{record.class.table_name}.#{field} = ?&quot;
-        conditions &lt;&lt; record.send(field)
-      end
-    end
-    
-    # Return an errorpage if the action requested is nonidempotent and the method used isn't POST
-    def scaffold_check_nonidempotent_requests
-      head(:method_not_allowed) if scaffolded_nonidempotent_method?(params[:action]) &amp;&amp; request.method != :post
-    end
-  
-    class &lt;&lt; self
-      attr_accessor :scaffolded_methods, :scaffolded_nonidempotent_methods
-      
-      # The location of the scaffold templates
-      def scaffold_template_dir
-        @scaffold_template_dir ||= @@scaffold_template_dir
-      end
-      
-      # The methods that should be added by the scaffolding function by default
-      def default_scaffold_methods
-        @default_scaffold_methods ||= @@default_scaffold_methods
-      end
-      
-      # Returns path to the given scaffold rhtml file
-      def scaffold_path(template_name)
-        File.join(scaffold_template_dir, template_name+'.rhtml')
-      end
-      
-      def scaffold_method(method_name) # :nodoc:
-        scaffolded_methods.add(method_name)
-        &quot;alias_method :#{method_name}, :_#{method_name}; private :_#{method_name};&quot;
-      end
-      
-      # Normalizes scaffold options, allowing submission of symbols or arrays
-      def normalize_scaffold_options(options)
-        case options
-          when Array then options
-          when Symbol then [options]
-          else []
-        end
-      end
-      
-      # Create controller instance method for returning results to the scaffold autocompletor
-      # for the given model.
-      def scaffold_auto_complete_for(object, options = {})
-        klass = object.to_s.camelize.constantize
-        define_method(&quot;scaffold_auto_complete_for_#{object}&quot;) do
-          options[:session_value] = session[klass.scaffold_session_value] if klass.scaffold_session_value
-          @items = klass.scaffold_auto_complete_find(params[:id], options)
-          render :inline =&gt; &quot;&lt;%= scaffold_auto_complete_result(@items) %&gt;&quot;
-        end
-      end
-      
-      # Setup scaffold auto complete for the model if it is requested by model
-      # and it hasn't already been setup.
-      def setup_scaffold_auto_complete_for(model_id)
-        scaffold_auto_complete_for(model_id) if model_id.to_s.camelize.constantize.scaffold_use_auto_complete &amp;&amp; !respond_to?(&quot;scaffold_auto_complete_for_#{model_id}&quot;)
-      end
-      
-      # Setup scaffold_auto_complete_for for the given controller for all models
-      # implementing scaffold autocompleting.  If scaffolding is used in multiple
-      # controllers, scaffold_auto_complete_for methods for all models will be added
-      # to all controllers.
-      def setup_scaffold_auto_completes
-        return if @scaffold_auto_completes_are_setup
-        ActiveRecord::Base.all_models.each{|model| setup_scaffold_auto_complete_for(model.to_sym)}
-        @scaffold_auto_completes_are_setup = true
-      end
-      
-      # Setup resources used by both scaffold and scaffold_habtm
-      def setup_shared_scaffolding
-        return if @scaffolding_shared_resources_are_setup
-        self.scaffolded_methods ||= Set.new
-        self.scaffolded_nonidempotent_methods ||= Set.new
-        before_filter :scaffold_check_nonidempotent_requests
-        @scaffolding_shared_resources_are_setup = true
-      end
-        
-      # Expands on the default Rails scaffold function.
-      # Takes the following additional options:
-      #
-      # - :except: symbol or array of method symbols not to add
-      # - :only: symbol or array of method symbols to use instead of the default
-      # - :habtm: symbol or array of symbols of habtm associated classes,
-      #   habtm scaffolds will be created for each one
-      # - :setup_auto_completes: if set to false, don't create scaffold auto
-      #   complete actions for all models
-      # - :generate: instead of evaluating the code produced, it outputs the code
-      #   functioning as a poor man's generator
-      #
-      # The following method symbols are used to control the methods that get
-      # added by the scaffold function:
-      #
-      # - :manage: Page that has links to all the other methods.  Also used
-      #   as the index page unless :suffix=&gt;true
-      # - :show: Shows a select box with all objects, allowing the user to chose
-      #   one, which then shows the attribute name and value for scaffolded fields
-      # - :destroy: Shows a select box with all objects, allowing the user to chose
-      #   one to delete
-      # - :edit: Shows a select box with all objects, allowing the user to chose
-      #   one to edit.  Also shows associations specified in the model's
-      #   scaffold_associations, allowing you easy access to manage associated models,
-      #   add new objects for has_many associations, and edit the has_and_belongs_to_many
-      #   associations.
-      # - :new: Form for creating new objects
-      # - :search: Simple search form using the same attributes as the new/edit 
-      #   form. The results page has links to show, edit, or destroy the object
-      # - :merge: Brings up two select boxes each populated with all objects,
-      #   allowing the user to pick one to merge into the other
-      # - :browse: Browse all model objects, similar to the default Rails list scaffold 
-      def scaffold(model_id, options = {})
-        options.assert_valid_keys(:class_name, :suffix, :except, :only, :habtm,
-          :setup_auto_completes, :scaffold_all_models, :generate)
-        
-        code = ''
-        setup_shared_scaffolding
-        singular_name = model_id.to_s.underscore
-        class_name    = options[:class_name] || singular_name.camelize
-        singular_class = class_name.constantize
-        plural_name   = singular_name.pluralize
-        suffix        = options[:suffix] ? &quot;_#{singular_name}&quot; : &quot;&quot;
-        add_methods = options[:only] ? normalize_scaffold_options(options[:only]) : self.default_scaffold_methods
-        add_methods -= normalize_scaffold_options(options[:except]) if options[:except]
-        normalize_scaffold_options(options[:habtm]).each{|habtm_association| code &lt;&lt; scaffold_habtm(model_id, habtm_association, (singular_class.scaffold_habtm_with_ajax ? {:ajax=&gt;true, :suffix=&gt;suffix} : {}).merge(:generate=&gt;options[:generate])).to_s}
-        setup_scaffold_auto_completes unless options[:setup_auto_completes] == false
-        session_value = singular_class.scaffold_session_value
-        session_ivalue = &quot;session[#{session_value.inspect}]&quot; if session_value
-        session_conditions = &quot;, :conditions=&gt;['#{singular_class.table_name}.#{session_value} = ?', #{session_ivalue}]&quot; if session_value
-        scaffold_raise = &quot;raise ActiveRecord::RecordNotFound unless @#{singular_name}.#{session_value} == #{session_ivalue}&quot; if session_value
-        
-        if add_methods.include?(:manage)
-          code &lt;&lt; &lt;&lt;-&quot;end_eval&quot;
-            def _manage#{suffix}
-              @scaffold_all_models ||= #{options[:scaffold_all_models] ? 'true' : 'false'}
-              render#{suffix}_scaffold &quot;manage#{suffix}&quot;
-            end
-            #{scaffold_method(&quot;manage#{suffix}&quot;)}
-            
-          end_eval
-          
-          unless options[:suffix]
-            scaffolded_methods.add(&quot;index&quot;)
-            code &lt;&lt; &lt;&lt;-&quot;end_eval&quot;
-              def index
-                manage
-              end
-              
-            end_eval
-          end
-        end
-        
-        if add_methods.include?(:show) or add_methods.include?(:destroy) or add_methods.include?(:edit)
-          scaffolded_methods.add(&quot;list#{suffix}&quot;)
-          code &lt;&lt; &lt;&lt;-&quot;end_eval&quot;
-            def list#{suffix}
-              unless #{singular_class.scaffold_use_auto_complete}
-                @#{plural_name} ||= #{class_name}.find(:all, :order=&gt;#{class_name}.scaffold_select_order, :include=&gt;#{class_name}.scaffold_include #{session_conditions})
-              end
-              render#{suffix}_scaffold &quot;list#{suffix}&quot;
-            end
-            private :list#{suffix}
-            
-          end_eval
-        end
-        
-        if add_methods.include?(:show)
-          code &lt;&lt; &lt;&lt;-&quot;end_eval&quot;
-            def _show#{suffix}
-              if params[:id]
-                @#{singular_name} ||= #{class_name}.find(params[:id].to_i)
-                #{scaffold_raise}
-                @scaffold_associations_readonly = true
-                render#{suffix}_scaffold
-              else
-                @scaffold_action = 'show'
-                list#{suffix}
-              end
-            end
-            #{scaffold_method(&quot;show#{suffix}&quot;)}
-            
-          end_eval
-        end
-        
-        if add_methods.include?(:delete)
-          scaffolded_nonidempotent_methods.add(&quot;destroy#{suffix}&quot;)
-          code &lt;&lt; &lt;&lt;-&quot;end_eval&quot;
-            def _delete#{suffix}
-              @scaffold_action = 'destroy'
-              list#{suffix}
-            end
-            #{scaffold_method(&quot;delete#{suffix}&quot;)}
-            
-            def _destroy#{suffix}
-              @#{singular_name} ||= #{class_name}.find(params[:id].to_i)
-              #{scaffold_raise}
-              @#{singular_name}.destroy
-              flash[:notice] = &quot;#{singular_name.humanize} was successfully destroyed&quot;
-              scaffold_delete_redirect('#{suffix}')
-            end
-            #{scaffold_method(&quot;destroy#{suffix}&quot;)}
-            
-          end_eval
-        end
-        
-        if add_methods.include?(:edit)
-          scaffolded_nonidempotent_methods.add(&quot;update#{suffix}&quot;)
-          code &lt;&lt; &lt;&lt;-&quot;end_eval&quot;
-            def _edit#{suffix}
-              if params[:id]
-                @#{singular_name} ||= #{class_name}.find(params[:id].to_i)
-                #{scaffold_raise}
-                render#{suffix}_scaffold
-              else
-                @scaffold_action = 'edit'
-                list#{suffix}
-              end
-            end
-            #{scaffold_method(&quot;edit#{suffix}&quot;)}
-            
-            def _update#{suffix}
-              @#{singular_name} ||= #{class_name}.find(params[:id])
-              #{scaffold_raise}
-              @#{singular_name}.update_scaffold_attributes(#{class_name}.scaffold_edit_fields_replacing_associations, params[:#{singular_name}])
-              
-              if @#{singular_name}.save
-                flash[:notice] = &quot;#{singular_name.humanize} was successfully updated&quot;
-                scaffold_edit_redirect('#{suffix}')
-              else
-                render#{suffix}_scaffold('edit')
-              end
-            end
-            #{scaffold_method(&quot;update#{suffix}&quot;)}
-            
-          end_eval
-          
-          if singular_class.scaffold_load_associations_with_ajax
-            code &lt;&lt; &lt;&lt;-&quot;end_eval&quot;
-            def _associations#{suffix}
-              @#{singular_name} ||= #{class_name}.find(params[:id].to_i)
-              #{scaffold_raise}
-              render#{suffix}_scaffold('associations', :inline=&gt;&quot;&lt;%= habtm_ajax_associations if @scaffold_class.scaffold_habtm_with_ajax %&gt;\\n&lt;%= association_links %&gt;\\n&quot;, :layout=&gt;false)
-            end
-            #{scaffold_method(&quot;associations#{suffix}&quot;)}
-            
-            end_eval
-          end
-        end
-        
-        if add_methods.include?(:new)
-          scaffolded_nonidempotent_methods.add(&quot;create#{suffix}&quot;)
-          code &lt;&lt; &lt;&lt;-&quot;end_eval&quot;
-            def _new#{suffix}
-              @#{singular_name} ||= #{class_name}.new(params[:#{singular_name}])
-              render#{suffix}_scaffold
-            end
-            #{scaffold_method(&quot;new#{suffix}&quot;)}
-            
-            def _create#{suffix}
-              @#{singular_name} ||= #{class_name}.new
-              @#{singular_name}.update_scaffold_attributes(#{class_name}.scaffold_new_fields_replacing_associations, params[:#{singular_name}])
-              #{&quot;@#{singular_name}.#{session_value} = #{session_ivalue}&quot; if session_value}
-              if @#{singular_name}.save
-                flash[:notice] = &quot;#{singular_name.humanize} was successfully created&quot;
-                params[:id] = @#{singular_name}.id
-                scaffold_new_redirect('#{suffix}')
-              else
-                render#{suffix}_scaffold('new')
-              end
-            end
-            #{scaffold_method(&quot;create#{suffix}&quot;)}
-            
-          end_eval
-        end
-        
-        if add_methods.include?(:search)
-          code &lt;&lt; &lt;&lt;-&quot;end_eval&quot;
-            def _search#{suffix}
-              unless @#{singular_name}
-                @#{singular_name} ||= #{class_name}.new
-                #{class_name}.column_names.each{|key| @#{singular_name}[key] = nil }
-              end
-              render#{suffix}_scaffold('search#{suffix}')
-            end
-            #{scaffold_method(&quot;search#{suffix}&quot;)}
-            
-            def _results#{suffix}
-              record = #{class_name}.new
-              record.update_scaffold_attributes(#{class_name}.scaffold_search_fields_replacing_associations, params[:#{singular_name}])
-              conditions = [[]]
-              
-              limit, offset = nil, nil
-              if #{singular_class.search_pagination_enabled?}
-                @scaffold_search_results_form_params = {&quot;#{singular_name}&quot;=&gt;{}, :notnull=&gt;[], :null=&gt;[]}
-                @scaffold_search_results_page = params[:page].to_i &gt; 1 ? params[:page].to_i : 1
-                @scaffold_search_results_page -= 1 if params[:page_previous]
-                @scaffold_search_results_page += 1 if params[:page_next]
-                limit = #{singular_class.scaffold_search_results_limit + 1}
-                offset = @scaffold_search_results_page &gt; 1 ? (limit-1)*(@scaffold_search_results_page - 1) : nil
-              end
-              
-              if params[:#{singular_name}]
-                #{class_name}.scaffold_search_fields_replacing_associations.each do |field|
-                  next if (params[:null] &amp;&amp; params[:null].include?(field)) || (params[:notnull] &amp;&amp; params[:notnull].include?(field)) || !params[:#{singular_name}][field] || params[:#{singular_name}][field].length == 0
-                  scaffold_search_add_condition(conditions, record, field)
-                  @scaffold_search_results_form_params[&quot;#{singular_name}&quot;][field] = params[:#{singular_name}][field] if #{singular_class.search_pagination_enabled?}
-                end
-              end
-              
-              #{class_name}.scaffold_search_fields_replacing_associations.each do |field|
-                if params[:null] &amp;&amp; params[:null].include?(field)
-                  conditions[0] &lt;&lt; &quot;#{singular_class.table_name}.\#{field} IS NULL&quot;
-                  @scaffold_search_results_form_params[:null] &lt;&lt; field if #{singular_class.search_pagination_enabled?}
-                end
-                if params[:notnull] &amp;&amp; params[:notnull].include?(field)
-                  conditions[0] &lt;&lt; &quot;#{singular_class.table_name}.\#{field} IS NOT NULL&quot;
-                  @scaffold_search_results_form_params[:notnull] &lt;&lt; field if #{singular_class.search_pagination_enabled?}
-                end
-              end
-              
-              #{&quot;conditions[0] &lt;&lt; '#{singular_class.table_name}.#{session_value} = ?'; conditions &lt;&lt; #{session_ivalue}&quot; if session_value}
-              conditions[0] = conditions[0].join(' AND ')
-              conditions = nil if conditions[0].length == 0
-              @#{plural_name} = #{class_name}.find(:all, :conditions=&gt;conditions, :include=&gt;#{class_name}.scaffold_search_include, :order=&gt;#{class_name}.scaffold_search_select_order, :limit=&gt;limit, :offset=&gt;offset)
-              @scaffold_search_results_page_next = true if #{singular_class.search_pagination_enabled?} &amp;&amp; @#{plural_name}.length == #{singular_class.scaffold_search_results_limit+1} &amp;&amp; @#{plural_name}.pop
-              @scaffold_fields_method = :scaffold_search_fields
-              render#{suffix}_scaffold('listtable#{suffix}')
-            end
-            #{scaffold_method(&quot;results#{suffix}&quot;)}
-            
-          end_eval
-        end
-      
-        if add_methods.include?(:merge)
-          scaffolded_nonidempotent_methods.add(&quot;merge_update#{suffix}&quot;)
-          code &lt;&lt; &lt;&lt;-&quot;end_eval&quot;
-            def _merge#{suffix}
-              unless #{singular_class.scaffold_use_auto_complete}
-                @#{plural_name} ||= #{class_name}.find(:all, :order=&gt;#{class_name}.scaffold_select_order, :include=&gt;#{class_name}.scaffold_include #{session_conditions})
-              end
-              render#{suffix}_scaffold('merge#{suffix}')
-            end
-            #{scaffold_method(&quot;merge#{suffix}&quot;)}
-            
-            def _merge_update#{suffix}
-              #{&quot;@#{singular_name} ||= #{class_name}.find(params[:from].to_i)&quot; if session_value}
-              #{scaffold_raise}
-              #{&quot;@#{singular_name} ||= #{class_name}.find(params[:to].to_i)&quot; if session_value}
-              #{scaffold_raise}
-              flash[:notice] = if #{class_name}.merge_records(params[:from].to_i, params[:to].to_i)
-                &quot;#{plural_name.humanize} were successfully merged&quot;
-              else &quot;Error merging #{plural_name.humanize.downcase}&quot;
-              end
-              scaffold_merge_redirect('#{suffix}')
-            end
-            #{scaffold_method(&quot;merge_update#{suffix}&quot;)}
-            
-          end_eval
-        end
-        
-        if add_methods.include?(:browse)
-          code &lt;&lt; &lt;&lt;-&quot;end_eval&quot;
-            def _browse#{suffix}
-              @page ||= params[:page].to_i &gt; 1 ? params[:page].to_i : 1
-              @#{plural_name} ||= #{class_name}.find(:all, :order=&gt;#{class_name}.scaffold_browse_select_order, :include=&gt;#{class_name}.scaffold_browse_include, :limit =&gt; #{singular_class.scaffold_browse_records_per_page+1}, :offset=&gt;((@page-1)*#{singular_class.scaffold_browse_records_per_page}) #{session_conditions})
-              @next_page ||= true if @#{plural_name}.length == #{singular_class.scaffold_search_results_limit+1} &amp;&amp; @#{plural_name}.pop
-              @scaffold_fields_method = :scaffold_browse_fields
-              render#{suffix}_scaffold('listtable#{suffix}')
-            end
-            #{scaffold_method(&quot;browse#{suffix}&quot;)}
-            
-          end_eval
-        end
-        
-        code &lt;&lt; &lt;&lt;-&quot;end_eval&quot;
-          add_template_helper(ScaffoldHelper)
-          
-          private
-            def render#{suffix}_scaffold(action=nil, options={})
-              action ||= caller_method_name(caller)
-              action = action[1..-1] if action[0...1] == '_' 
-              @scaffold_class ||= #{class_name}
-              @scaffold_singular_name ||= &quot;#{singular_name}&quot;
-              @scaffold_plural_name ||= &quot;#{plural_name}&quot;
-              @scaffold_methods ||= #{add_methods.inspect}
-              @scaffold_suffix ||= &quot;#{suffix}&quot;
-              @scaffold_singular_object ||= @#{singular_name}
-              @scaffold_plural_object ||= @#{plural_name}
-              add_instance_variables_to_assigns
-              render_scaffold_template(action, options)
-            end
-        end_eval
-        
-        options[:generate] ? code : module_eval(code, __FILE__)
-      end
-      
-      # Scaffolds a habtm association for two classes using two select boxes, or
-      # a select box for removing associations and an autocompleting text box for
-      # adding associations. By default, scaffolds the association both ways.
-      # 
-      # The new way of calling this is with symbols naming the model and the
-      # association, and an optional hash of options.  The old method of having
-      # an optional true/false flag still works.
-      #
-      # Possibly options:
-      # - :both_ways - scaffold the association both ways
-      # - :suffix - only needed for redirects for non-Ajax browsers using the ajax form, used by scaffold      
-      # - :generate - return code generated instead of evaluating it
-      def scaffold_habtm(singular, many, options = true)
-        setup_shared_scaffolding
-        options = options.is_a?(Hash) ? Hash.new.merge(options) : {:both_ways=&gt;options}
-        singular_class = singular.to_s.camelize.constantize
-        singular_name = singular_class.name
-        reflection = singular_class.reflect_on_association(many.to_s.pluralize.underscore.to_sym)
-        return false if reflection.nil? or reflection.macro != :has_and_belongs_to_many
-        many_class = (reflection.options[:class_name] || many.to_s.camelize).constantize
-        many_class_name = many_class.name
-        many_name = many.to_s.pluralize.underscore
-        setup_scaffold_auto_complete_for(many_class_name.underscore.to_sym)
-        foreign_key = reflection.primary_key_name
-        association_foreign_key = reflection.association_foreign_key
-        join_table = reflection.options[:join_table]
-        session_svalue = singular_class.scaffold_session_value
-        session_mvalue = many_class.scaffold_session_value
-        code = if options[:ajax]
-          scaffolded_methods.add(&quot;add_#{many}_to_#{singular}&quot;)
-          scaffolded_methods.add(&quot;remove_#{many}_from_#{singular}&quot;)
-          scaffolded_nonidempotent_methods.add(&quot;add_#{many}_to_#{singular}&quot;)
-          scaffolded_nonidempotent_methods.add(&quot;remove_#{many}_from_#{singular}&quot;)
-          suffix = options[:suffix]
-          scaffold_sraise = &quot;raise ActiveRecord::RecordNotFound unless @record.#{session_svalue} == session[#{session_svalue.inspect}]&quot; if session_svalue
-          scaffold_mraise = &quot;raise ActiveRecord::RecordNotFound unless @associated_record.#{session_mvalue} == session[#{session_mvalue.inspect}]&quot; if session_mvalue
-          &lt;&lt;-&quot;end_eval&quot;
-            def add_#{many}_to_#{singular}
-              @record = #{singular_name}.find(params[:id].to_i)
-              #{scaffold_sraise}
-              @associated_record = #{many_class_name}.find(params[:#{singular}_#{many}_id].to_i)
-              #{scaffold_mraise}
-              #{singular_name}.connection.execute(&quot;INSERT INTO #{join_table} (#{foreign_key}, #{association_foreign_key}) VALUES (\#{@record.id}, \#{@associated_record.id})&quot;)
-              if request.xhr?
-                render :update do |page|
-                  page.insert_html(:top, '#{singular}_associated_records_list', :inline=&gt;&quot;&lt;%= scaffold_habtm_association_line_item(@record, '#{singular}', @associated_record, '#{many}') %&gt;&quot;)
-                  #{&quot;page.remove(\&quot;#{singular}_#{many}_id_\#{@associated_record.id}\&quot;)&quot; unless reflection.klass.scaffold_use_auto_complete}
-                  page[&quot;#{singular}_#{many}_id&quot;].#{reflection.klass.scaffold_use_auto_complete ? &quot;value = ''&quot; : &quot;selectedIndex = 0&quot;}
-                end
-              else redirect_to(:action=&gt;&quot;edit#{suffix}&quot;, :id=&gt;@record.id)
-              end
-            end
-              
-            def remove_#{many}_from_#{singular}
-              @record = #{singular_name}.find(params[:id].to_i)
-              #{scaffold_sraise}
-              @associated_record = #{many_class_name}.find(params[:#{singular}_#{many}_id].to_i)
-              #{scaffold_mraise}
-              @record.#{many_name}.delete(@associated_record)
-              if request.xhr?
-                render(:update) do |page| 
-                  page.remove(&quot;#{singular}_\#{@record.id}_#{many}_\#{@associated_record.id}&quot;)
-                  #{&quot;page.insert_html(:bottom, '#{singular}_#{many}_id', \&quot;&lt;option value='\#{@associated_record.id}' id='#{singular}_#{many}_id_\#{@associated_record.id}'&gt;\#{@associated_record.scaffold_name}&lt;/option&gt;\&quot;)&quot; unless reflection.klass.scaffold_use_auto_complete}
-                end
-              else redirect_to(:action=&gt;&quot;edit#{suffix}&quot;, :id=&gt;@record.id)
-              end
-            end
-            
-          end_eval
-        else
-          suffix = &quot;_#{singular_name.underscore}_#{many_name}&quot; 
-          scaffolded_methods.add(&quot;edit#{suffix}&quot;)
-          scaffolded_methods.add(&quot;update#{suffix}&quot;)
-          scaffolded_nonidempotent_methods.add(&quot;update#{suffix}&quot;)
-          scaffold_mraise = &quot;raise ActiveRecord::RecordNotFound unless @associated_record.#{session_mvalue} == session[#{session_mvalue.inspect}]&quot; if session_mvalue
-          scaffold_mconditions = &quot;conditions[0] &lt;&lt; 'AND #{session_mvalue} = ?'; conditions &lt;&lt; session[#{session_mvalue.inspect}]&quot; if session_mvalue
-          &lt;&lt;-&quot;end_eval&quot;
-            def edit#{suffix}
-              @singular_name = &quot;#{singular_name}&quot; 
-              @many_name = &quot;#{many_name.gsub('_',' ')}&quot; 
-              @singular_object = #{singular_name}.find(params[:id])
-              #{&quot;raise ActiveRecord::RecordNotFound unless @singular_object.#{session_svalue} == session[#{session_svalue.inspect}]&quot; if session_svalue}
-              @many_class = #{many_class_name}
-              conditions = [&quot;#{many_class.primary_key} IN (SELECT #{association_foreign_key} FROM #{join_table} WHERE #{join_table}.#{foreign_key} = ?)&quot;, params[:id].to_i]
-              #{scaffold_mconditions}
-              @items_to_remove = #{many_class_name}.find(:all, :conditions=&gt;conditions, :order=&gt;#{many_class_name}.scaffold_select_order).collect{|item| [item.scaffold_name, item.id]}
-              unless #{many_class.scaffold_use_auto_complete}
-                conditions = [&quot;#{many_class.primary_key} NOT IN (SELECT #{association_foreign_key} FROM #{join_table} WHERE #{join_table}.#{foreign_key} = ?)&quot;, params[:id].to_i]
-                #{scaffold_mconditions}
-                @items_to_add = #{many_class_name}.find(:all, :conditions=&gt;conditions, :order=&gt;#{many_class_name}.scaffold_select_order).collect{|item| [item.scaffold_name, item.id]}
-              end
-              @scaffold_update_page = &quot;update#{suffix}&quot; 
-              render_scaffold_template(&quot;habtm#{suffix}&quot;)
-            end
-            
-            def update#{suffix}
-              flash[:notice], success = begin
-                singular_item = #{singular_name}.find(params[:id])
-                #{&quot;raise ActiveRecord::RecordNotFound unless singular_item.#{session_svalue} == session[#{session_svalue.inspect}]&quot; if session_svalue}
-                if params[:add] &amp;&amp; !params[:add].empty?
-                  #{singular_name}.transaction do
-                    multiple_select_ids(params[:add]).each do |associated_record_id|
-                      #{&quot;raise ActiveRecord::RecordNotFound unless #{many_class_name}.find(associated_record_id).#{session_mvalue} == session[#{session_mvalue.inspect}]&quot; if session_mvalue}
-                      #{singular_name}.connection.execute(&quot;INSERT INTO #{join_table} (#{foreign_key}, #{association_foreign_key}) VALUES (\#{singular_item.id}, \#{associated_record_id})&quot;)
-                    end
-                  end 
-                end
-                if params[:remove] &amp;&amp; !params[:remove].empty?
-                  many_items = #{many_class_name}.find(multiple_select_ids(params[:remove]))
-                  #{&quot;many_items.each{|item| raise ActiveRecord::RecordNotFound unless item.#{session_mvalue} == session[#{session_mvalue.inspect}]}&quot; if session_mvalue}
-                  singular_item.#{many_name}.delete(many_items)
-                end
-                [&quot;Updated #{singular_name.underscore.humanize.downcase}'s #{many_name.humanize.downcase} successfully&quot;, true]
-              rescue ::ActiveRecord::StatementInvalid
-                [&quot;Error updating #{singular_name.underscore.humanize.downcase}'s #{many_name.humanize.downcase}&quot;, false]
-              end
-              scaffold_habtm_redirect('#{suffix}', success)
-            end
-            
-          end_eval
-        end
-        code &lt;&lt; scaffold_habtm(many_class_name, singular_name, options.merge(:both_ways=&gt;false)).to_s if options[:both_ways] &amp;&amp; !reflection.options[:class_name]
-        options[:generate] ? code : module_eval(code, __FILE__)
-      end
-      
-      # Scaffolds all models in the Rails app, with all associations when called
-      # with no arguments.  
-      #
-      # There are two ways to call it with arguments:
-      # - Multiple string or symbol arguments specify models to be scaffolded.  No
-      #   other models will be scaffolded (deprecated)
-      # - One hash with the following symbols as keys:
-      #   - :except =&gt; Array  # Don't scaffold these models
-      #   - :only   =&gt; Array  # Only scaffold these models
-      #   - :generate =&gt; true/false # Emit code generated instead of evaluating it
-      #   - * (Everything else) =&gt; Hash 
-      #     - Key is a symbol with the class name underscored.
-      #     - Value is a hash of scaffold options.
-      #     - To use a different singular name, use :model_id=&gt;'singular_name' inside the value hash
-      def scaffold_all_models(*models)
-        self.scaffolded_methods ||= Set.new
-        models = parse_scaffold_all_models_options(*models)
-        model_names = []
-        scaffold_results = models.collect{|model, options| model_names &lt;&lt; model.to_s; scaffold(model, options)}.compact
-        code = &lt;&lt;-&quot;end_eval&quot;
-          def index
-            @models = #{model_names.inspect}
-            render_scaffold_template(&quot;index&quot;)
-          end
-        end_eval
-        scaffold_results.length &gt; 0 ? scaffold_results.push(code).join(&quot;\n\n&quot;) : module_eval(code, __FILE__)
-      end
-      
-      # Parse the arguments for scaffold_all_models.  Seperated so that it can
-      # also be used in testing.
-      def parse_scaffold_all_models_options(*models)
-        options = models.pop if models.length &gt; 0 &amp;&amp; Hash === models[-1]
-        generate = options.delete(:generate) if options
-        except = options.delete(:except) if options
-        only = options.delete(:only) if options
-        except.collect!(&amp;:to_s) if except
-        only.collect!(&amp;:to_s) if only
-        models = ActiveRecord::Base.all_models if options || models.length == 0
-        models.delete_if{|model| except.include?(model)} if except
-        models.delete_if{|model| !only.include?(model)} if only
-        models.collect do |model|
-          scaffold_options = {:suffix=&gt;true, :scaffold_all_models=&gt;true, :generate=&gt;generate, :habtm=&gt;model.to_s.camelize.constantize.scaffold_habtm_reflections.collect{|r|r.name.to_s.singularize}}
-          scaffold_options.merge!(options[model.to_sym]) if options &amp;&amp; options.include?(model.to_sym)
-          scaffold_model = scaffold_options.delete(:model_id) || model.to_sym
-          [scaffold_model, scaffold_options]
-        end
-      end
-    end
-  end
-end
+require 'scaffolding_extensions/model/active_record' if defined? ActiveRecord::Base
+  
\ No newline at end of file</diff>
      <filename>lib/scaffolding_extensions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,12 @@
-&lt;h1&gt;Editing &lt;%= @scaffold_singular_name.humanize.downcase %&gt;&lt;/h1&gt;
+&lt;% @scaffold_title = &quot;Editing #{@scaffold_options[:singular_lc_human_name]}&quot; %&gt;
 
-&lt;%= scaffold_form('update', :fields=&gt;@scaffold_class.scaffold_edit_fields) %&gt;
+&lt;%= scaffold_model_form('update', @scaffold_class.scaffold_fields(:edit)) %&gt;
 
 &lt;% if @scaffold_class.scaffold_load_associations_with_ajax %&gt;
-  &lt;%= content_tag(:div, link_to_remote(&quot;Modify Associations&quot;, :update=&gt;&quot;scaffold_ajax_content_#{@scaffold_singular_object.id}&quot;, :url=&gt;{:action=&gt;&quot;associations_#{@scaffold_singular_name}&quot;, :id=&gt;@scaffold_singular_object.id}), :id=&gt;&quot;scaffold_ajax_content_#{@scaffold_singular_object.id}&quot;) %&gt;
+  &lt;%= scaffold_load_associations_with_ajax_link %&gt;
 &lt;% else %&gt;
-  &lt;%= habtm_ajax_associations if @scaffold_class.scaffold_habtm_with_ajax %&gt;
-  &lt;%= association_links %&gt;
+  &lt;%= scaffold_habtm_ajax_associations %&gt;
+  &lt;%= scaffold_association_links %&gt;
 &lt;% end %&gt;
 
-&lt;%= manage_link %&gt;
+&lt;%= scaffold_manage_link %&gt;</diff>
      <filename>scaffolds/edit.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,20 +1,24 @@
-&lt;h3&gt;Edit &lt;%=h @singular_object.scaffold_name %&gt;'s &lt;%= @many_name %&gt; &lt;/h3&gt;
+&lt;% @scaffold_title = &quot;Update #{sn = h(@scaffold_object.scaffold_name)}'s #{mpn = (so = @scaffold_options )[:aplch_name]}&quot; %&gt;
 
-&lt;%= form_tag(:action=&gt;@scaffold_update_page, :id=&gt;params[:id]) %&gt;
+&lt;%= scaffold_form(scaffold_url(&quot;update#{@scaffold_suffix}&quot;, :id=&gt;(soid=@scaffold_object.scaffold_id))) %&gt;
 
-&lt;% if @many_class.scaffold_use_auto_complete %&gt;
-  &lt;h4&gt;Add This &lt;%= @many_name.singularize.humanize %&gt;&lt;/h4&gt;
-  &lt;%= scaffold_text_field_tag_with_auto_complete('add', @many_class) %&gt;
+&lt;% if @scaffold_class.scaffold_association_use_auto_complete(assoc = so[:association]) %&gt;
+  &lt;h4&gt;Add this &lt;%= so[:aslhc_name] %&gt;&lt;/h4&gt;
+  &lt;%= scaffold_text_field_tag_with_auto_complete('add', so[:singular_name], assoc) %&gt;
 &lt;% elsif @items_to_add.length &gt; 0 %&gt;
-  &lt;h4&gt;Add These &lt;%= @many_name.humanize %&gt;&lt;/h4&gt;
-  &lt;%= select_tag('add[]', options_for_select(@items_to_add), :id=&gt;'add', :multiple=&gt;'multiple') %&gt;
+  &lt;h4&gt;Add these &lt;%= mpn %&gt;&lt;/h4&gt;
+  &lt;%= scaffold_select_tag('add', @items_to_add, true) %&gt;
 &lt;% end %&gt;
 
 &lt;% if @items_to_remove.length &gt; 0 %&gt; 
-  &lt;h4&gt;Remove These &lt;%= @many_name.humanize %&gt;&lt;/h4&gt;
-  &lt;%= select_tag('remove[]', options_for_select(@items_to_remove), :id=&gt;'remove', :multiple=&gt;'multiple') %&gt;
+  &lt;h4&gt;Remove these &lt;%= mpn %&gt;&lt;/h4&gt;
+  &lt;%= scaffold_select_tag('remove', @items_to_remove, true) %&gt;
 &lt;% end %&gt;
 
 &lt;br /&gt;&lt;br /&gt;
-&lt;%= submit_tag(&quot;Update&quot;) %&gt;
+&lt;input type='submit' value=&quot;Update &lt;%= sn %&gt;'s &lt;%= mpn %&gt;&quot; /&gt;
 &lt;/form&gt;
+
+&lt;% if '' != (edit_link = scaffold_check_link(&quot;Edit #{sn}&quot;, true, &quot;edit_#{@scaffold_options[:singular_name]}&quot;, :id=&gt;soid)) %&gt;
+  &lt;h2&gt;&lt;%= edit_link %&gt;&lt;/h2&gt;
+&lt;% end %&gt;</diff>
      <filename>scaffolds/habtm.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
-&lt;h1&gt;Manage Models&lt;/h1&gt;
+&lt;% @scaffold_title = 'Manage Models' %&gt;
 &lt;ul&gt;
-&lt;% @models.each do |model| %&gt;
-  &lt;%= content_tag(:li, link_to(model.humanize.pluralize, :action=&gt;&quot;manage_#{model}&quot;)) %&gt;
+&lt;% @links.each do |link, human_name| -%&gt;
+  &lt;li&gt;&lt;a href=&quot;&lt;%= scaffold_url(link) %&gt;&quot;&gt;&lt;%= human_name %&gt;&lt;/a&gt;&lt;/li&gt;
 &lt;% end %&gt;
 &lt;/ul&gt;</diff>
      <filename>scaffolds/index.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 &lt;html&gt;
 &lt;head&gt;
-  &lt;title&gt;Scaffolding&lt;/title&gt;
+  &lt;title&gt;Scaffolding Extensions&lt;%= &quot; - #{@scaffold_title}&quot; if @scaffold_title %&gt;&lt;/title&gt;
   &lt;style type=&quot;text/css&quot;&gt;
     body { background-color: #fff; color: #333; }
 
@@ -21,48 +21,39 @@
     a { color: #000; }
     a:visited { color: #666; }
     a:hover { color: #fff; background-color:#000; }
-
-    .fieldWithErrors {
-      padding: 2px;
-      background-color: red;
-      display: table;
+    
+    div.habtm_ajax_remove_associations form { display: inline; }
+    
+    div.auto_complete {
+      width: 350px;
+      background: #fff;
     }
-
-    #ErrorExplanation {
-      width: 400px;
-    	border: 2px solid #red;
-    	padding: 7px;
-    	padding-bottom: 12px;
-    	margin-bottom: 20px;
-    	background-color: #f0f0f0;
+    div.auto_complete ul {
+      border:1px solid #888;
+      margin:0;
+      padding:0;
+      width:100%;
+      list-style-type:none;
     }
-
-    #ErrorExplanation h2 {
-    	text-align: left;
-    	font-weight: bold;
-    	padding: 5px 5px 5px 15px;
-    	font-size: 12px;
-    	margin: -7px;
-    	background-color: #c00;
-    	color: #fff;
+    div.auto_complete ul li {
+      margin:0;
+      padding:3px;
     }
-
-    #ErrorExplanation p {
-    	color: #333;
-    	margin-bottom: 0;
-    	padding: 5px;
+    div.auto_complete ul li.selected { 
+      background-color: #ffb; 
     }
-
-    #ErrorExplanation ul li {
-    	font-size: 12px;
-    	list-style: square;
+    div.auto_complete ul strong.highlight { 
+      color: #800; 
+      margin:0;
+      padding:0;
     }
   &lt;/style&gt;
 &lt;/head&gt;
 &lt;body&gt;
-&lt;h4&gt;&lt;%= flash[:notice] %&gt;&lt;/h4&gt;
+&lt;%= &quot;&lt;h1&gt;#{@scaffold_title}&lt;/h1&gt;&quot; if @scaffold_title %&gt;
+&lt;%= &quot;&lt;h4&gt;#{scaffold_flash[:notice]}&lt;/h4&gt;&quot; if scaffold_flash[:notice] %&gt;
 
-&lt;%= @content_for_layout %&gt;
+&lt;%= @content %&gt;
 
 &lt;/body&gt;
 &lt;/html&gt;</diff>
      <filename>scaffolds/layout.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,13 @@
-&lt;h1&gt;Choose &lt;%= @scaffold_singular_name.humanize.downcase %&gt; to &lt;%= @scaffold_action.humanize.downcase %&gt;&lt;/h1&gt;
+&lt;% @scaffold_title = &quot;Choose #{hn = @scaffold_options[:singular_lc_human_name]} to #{(haction = (action = @scaffold_action).to_s.humanize).downcase}&quot; %&gt;
 
-&lt;% form_tag({:action=&gt;&quot;#{@scaffold_action}#{@scaffold_suffix}&quot;}, {:method=&gt;(@scaffold_action == 'destroy' ? :post : :get)}) do %&gt;
-  &lt;% if @scaffold_class.scaffold_use_auto_complete %&gt;
-    &lt;%= scaffold_text_field_tag_with_auto_complete('id', @scaffold_class) %&gt;
-  &lt;% else %&gt;
-    &lt;%= select_tag('id', &quot;&lt;option value=''&gt;&amp;nbsp;&lt;/option&gt;&quot;+options_from_collection_for_select(@scaffold_plural_object, :id, :scaffold_name)) %&gt;
-  &lt;% end %&gt;
-  &lt;br /&gt;&lt;br /&gt;
-  &lt;input type=&quot;submit&quot; value=&quot;&lt;%= @scaffold_action.humanize %&gt; &lt;%= @scaffold_singular_name.humanize.downcase %&gt;&quot; /&gt;
+&lt;%= scaffold_form(scaffold_url(&quot;#{action}#{@scaffold_suffix}&quot;), :method=&gt;(action == :destroy ? :post : :get)) %&gt;
+&lt;% if @scaffold_class.scaffold_use_auto_complete %&gt;
+  &lt;%= scaffold_text_field_tag_with_auto_complete('id', @scaffold_options[:singular_name]) %&gt;
+&lt;% else %&gt;
+  &lt;%= scaffold_select_tag('id', @scaffold_objects) %&gt;
 &lt;% end %&gt;
+&lt;br /&gt;&lt;br /&gt;
+&lt;input type=&quot;submit&quot; value=&quot;&lt;%= haction %&gt; &lt;%= hn %&gt;&quot; /&gt;
+&lt;/form&gt;
 
-&lt;%= manage_link %&gt;
+&lt;%= scaffold_manage_link %&gt;</diff>
      <filename>scaffolds/list.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,46 +1,46 @@
-&lt;h1&gt;Listing &lt;%= @scaffold_plural_name.humanize.downcase %&gt;&lt;/h1&gt;
+&lt;% @scaffold_title = &quot;Listing #{@scaffold_options[:plural_lc_human_name]}&quot; %&gt;
 
-&lt;table id=&quot;scaffolded&quot; class=&quot;&lt;%= @scaffold_class.scaffold_table_class :list %&gt;&quot;&gt;
+&lt;table id=&quot;scaffolded&quot; class=&quot;&lt;%= @scaffold_class.scaffold_table_class(:list) %&gt;&quot;&gt;
   &lt;thead&gt;&lt;tr&gt;
-  &lt;% @scaffold_class.send(@scaffold_fields_method || :scaffold_fields).each do |column| -%&gt;
-    &lt;th&gt;&lt;%= @scaffold_class.scaffold_column_name(column) %&gt;&lt;/th&gt;
+  &lt;% @scaffold_class.scaffold_fields(@scaffold_listtable_type).each do |column| -%&gt;
+    &lt;th&gt;&lt;%=h @scaffold_class.scaffold_column_name(column) %&gt;&lt;/th&gt;
   &lt;% end %&gt;
-  &lt;%= content_tag(:th, 'Show') if @scaffold_methods.include?(:show) %&gt;
-  &lt;%= content_tag(:th, 'Edit') if @scaffold_methods.include?(:edit) %&gt;
-  &lt;%= content_tag(:th, 'Destroy') if @scaffold_methods.include?(:destroy) %&gt;
+  &lt;%= &quot;&lt;th&gt;#{s = 'Show'}&lt;/th&gt;&quot; if show = scaffolded_method?(ss = &quot;show#{@scaffold_suffix}&quot;) %&gt;
+  &lt;%= &quot;&lt;th&gt;#{e = 'Edit'}&lt;/th&gt;&quot; if edit = scaffolded_method?(es = &quot;edit#{@scaffold_suffix}&quot;) %&gt;
+  &lt;%= &quot;&lt;th&gt;#{d = 'Delete'}&lt;/th&gt;&quot; if delete = scaffolded_method?(ds = &quot;destroy#{@scaffold_suffix}&quot;) %&gt;
   &lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
-&lt;% @scaffold_plural_object.each do |entry| %&gt;
+&lt;% @scaffold_objects.each do |entry| eid = entry.scaffold_id  %&gt;
   &lt;tr&gt;
-  &lt;% @scaffold_class.send(@scaffold_fields_method || :scaffold_fields).each do |column|  %&gt;
-    &lt;td&gt;&lt;%=h scaffold_value(entry, column) %&gt;&lt;/td&gt;
+  &lt;% @scaffold_class.scaffold_fields(@scaffold_listtable_type).each do |column| %&gt;
+    &lt;td&gt;&lt;%=h entry.scaffold_value(column) %&gt;&lt;/td&gt;
   &lt;% end %&gt;
-  &lt;%= content_tag(:td, button_to('Show', :action=&gt;&quot;show#{@scaffold_suffix}&quot;, :id=&gt;entry.id)) if @scaffold_methods.include?(:show) %&gt;
-  &lt;%= content_tag(:td, button_to('Edit', :action=&gt;&quot;edit#{@scaffold_suffix}&quot;, :id=&gt;entry.id)) if @scaffold_methods.include?(:edit) %&gt;
-  &lt;%= content_tag(:td, button_to('Destroy', :action=&gt;&quot;destroy#{@scaffold_suffix}&quot;, :id=&gt;entry.id)) if @scaffold_methods.include?(:destroy) %&gt;
+  &lt;%= &quot;&lt;td&gt;#{scaffold_button_to(s, scaffold_url(ss, :id=&gt;eid), :method=&gt;:get)}&lt;/td&gt;&quot; if show %&gt;
+  &lt;%= &quot;&lt;td&gt;#{scaffold_button_to(e, scaffold_url(es, :id=&gt;eid), :method=&gt;:get)}&lt;/td&gt;&quot; if edit %&gt;
+  &lt;%= &quot;&lt;td&gt;#{scaffold_button_to(d, scaffold_url(ds, :id=&gt;eid))}&lt;/td&gt;&quot; if delete %&gt;
   &lt;/tr&gt;
 &lt;% end %&gt;
 &lt;/tbody&gt;&lt;/table&gt;
 
-&lt;% if @page %&gt;
-  &lt;%= link_to(&quot;Previous page&quot;, {:page=&gt;@page-1})  if @page &gt; 1 %&gt;
-  &lt;%= link_to(&quot;Next page&quot;, {:page=&gt;@page+1}) if @next_page %&gt; 
+&lt;% if @scaffold_listtable_type == :browse %&gt;
+  &lt;%= &quot;&lt;a href='#{scaffold_url(&quot;browse#{@scaffold_suffix}&quot;, :page=&gt;(@page-1))}'&gt;Previous Page&lt;/a&gt;&quot; if @page &gt; 1 %&gt;
+  &lt;%= &quot;&lt;a href='#{scaffold_url(&quot;browse#{@scaffold_suffix}&quot;, :page=&gt;(@page+1))}'&gt;Next Page&lt;/a&gt;&quot; if @next_page %&gt;
 &lt;% end %&gt;
 
-&lt;% if @scaffold_search_results_form_params %&gt;
-  &lt;% form_tag(:action=&gt;&quot;results#{@scaffold_suffix}&quot;) do %&gt;
-    &lt;%= hidden_field_tag('page', @scaffold_search_results_page) %&gt;
-    &lt;% @scaffold_search_results_form_params[@scaffold_singular_name].each do |key, value| -%&gt;
-      &lt;%= hidden_field_tag(&quot;#{@scaffold_singular_name}[#{key}]&quot;, value, :id=&gt;&quot;#{@scaffold_singular_name}_#{key}&quot;) %&gt;
-    &lt;% end %&gt;
-    &lt;% @scaffold_search_results_form_params[:notnull].each do |field| -%&gt;
-      &lt;%= hidden_field_tag(&quot;notnull[]&quot;, field, :id=&gt;&quot;notnull_&quot;) %&gt;
-    &lt;% end %&gt;
-    &lt;% @scaffold_search_results_form_params[:null].each do |field| -%&gt;
-      &lt;%= hidden_field_tag(&quot;null[]&quot;, field, :id=&gt;'null_') %&gt;
-    &lt;% end %&gt;
-    &lt;%= '&lt;input type=&quot;submit&quot; name=&quot;page_previous&quot; value=&quot;Previous Page&quot; &gt;' if @scaffold_search_results_page &gt; 1 %&gt;
-    &lt;%= '&lt;input type=&quot;submit&quot; name=&quot;page_next&quot; value=&quot;Next Page&quot; &gt;' if @scaffold_search_results_page_next %&gt;
+&lt;% if @scaffold_listtable_type == :search &amp;&amp; @scaffold_search_results_form_params &amp;&amp; (@scaffold_search_results_form_params[:page] &gt; 1 || @scaffold_search_results_form_params[:next_page]) %&gt;
+  &lt;%= scaffold_form(scaffold_url(&quot;results#{@scaffold_suffix}&quot;)) %&gt;
+  &lt;%= scaffold_field_tag(:hidden, :value=&gt;@scaffold_search_results_form_params[:page], :id=&gt;'page') %&gt;
+  &lt;% @scaffold_search_results_form_params[:model].each do |key, value| -%&gt;
+    &lt;%= scaffold_field_tag(:hidden, :value=&gt;value, :id=&gt;&quot;#{@scaffold_singular_name}_#{key}&quot;, :name=&gt;&quot;#{@scaffold_singular_name}[#{key}]&quot;) %&gt;
   &lt;% end %&gt;
+  &lt;% @scaffold_search_results_form_params[:notnull].each do |field| -%&gt;
+    &lt;%= scaffold_field_tag(:hidden, :value=&gt;field, :id=&gt;'notnull', :name=&gt;&quot;notnull#{scaffold_param_list_suffix}&quot;) %&gt;
+  &lt;% end %&gt;
+  &lt;% @scaffold_search_results_form_params[:null].each do |field| -%&gt;
+    &lt;%= scaffold_field_tag(:hidden, :value=&gt;field, :id=&gt;'null', :name=&gt;&quot;null#{scaffold_param_list_suffix}&quot;) %&gt;
+  &lt;% end %&gt;
+  &lt;%= '&lt;input type=&quot;submit&quot; name=&quot;page_previous&quot; value=&quot;Previous Page&quot; &gt;' if @scaffold_search_results_form_params[:page] &gt; 1 %&gt;
+  &lt;%= '&lt;input type=&quot;submit&quot; name=&quot;page_next&quot; value=&quot;Next Page&quot; &gt;' if @scaffold_search_results_form_params[:next_page] %&gt;
+  &lt;/form&gt;
 &lt;% end %&gt;
 
-&lt;%= manage_link %&gt;
+&lt;%= scaffold_manage_link %&gt;</diff>
      <filename>scaffolds/listtable.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,15 +1,15 @@
-&lt;h1&gt;Manage &lt;%= @scaffold_plural_name.humanize.downcase %&gt;&lt;/h1&gt;
+&lt;% @scaffold_title = &quot;Manage #{plural_name = @scaffold_options[:plural_lc_human_name]}&quot; %&gt;
 &lt;ul&gt;
-&lt;% {&quot;Create #{@scaffold_singular_name.humanize.downcase}&quot;=&gt;:new,
-&quot;Edit #{@scaffold_singular_name.humanize.downcase}&quot;=&gt;:edit,
-&quot;Destroy #{@scaffold_singular_name.humanize.downcase}&quot;=&gt;:delete,
-&quot;Show #{@scaffold_singular_name.humanize.downcase}&quot;=&gt;:show,
-&quot;Search #{@scaffold_plural_name.humanize.downcase}&quot;=&gt;:search,
-&quot;Merge #{@scaffold_plural_name.humanize.downcase}&quot;=&gt;:merge,
-&quot;Browse #{@scaffold_plural_name.humanize.downcase}&quot;=&gt;:browse
-}.sort.each do |text, action| %&gt;
-  &lt;%= content_tag(:li, link_to(text, :action=&gt;&quot;#{action}#{@scaffold_suffix}&quot;)) if @scaffold_methods.include?(action) %&gt;
+&lt;% [[&quot;Browse #{plural_name}&quot;, :browse],
+[&quot;Create #{singular_name = @scaffold_options[:singular_lc_human_name]}&quot;, :new],
+[&quot;Delete #{singular_name}&quot;, :delete],
+[&quot;Edit #{singular_name}&quot;, :edit],
+[&quot;Merge #{plural_name}&quot;, :merge],
+[&quot;Search #{plural_name}&quot;, :search],
+[&quot;Show #{singular_name}&quot;, :show]].each do |text, action| -%&gt;
+  &lt;% link = scaffold_check_link(text, true, &quot;#{action}#{@scaffold_suffix}&quot;) -%&gt;
+  &lt;%= &quot;&lt;li&gt;#{link}&lt;/li&gt;&quot; unless link == '' %&gt;
 &lt;% end %&gt;
 &lt;/ul&gt;
 
-&lt;%= link_to('Manage Models', :action=&gt;'index') if @scaffold_all_models %&gt;
+&lt;%= scaffold_check_link('Manage Models', true, 'index') %&gt;</diff>
      <filename>scaffolds/manage.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,23 +1,23 @@
-&lt;h1&gt;Merge two &lt;%= @scaffold_plural_name.humanize.downcase %&gt;&lt;/h1&gt;
+&lt;% @scaffold_title = &quot;Merge two #{@scaffold_options[:plural_lc_human_name]}&quot; %&gt;
 
-&lt;% form_tag(:action=&gt;&quot;merge_update#{@scaffold_suffix}&quot;) do %&gt;
-  &lt;p&gt;Merge:
-  &lt;% if @scaffold_class.scaffold_use_auto_complete %&gt;
-    &lt;%= scaffold_text_field_tag_with_auto_complete('from', @scaffold_class) %&gt;
-  &lt;% else %&gt;
-    &lt;%= select_tag('from', &quot;&lt;option value=''&gt;&amp;nbsp;&lt;/option&gt;&quot;+options_from_collection_for_select(@scaffold_plural_object, :id, :scaffold_name)) %&gt;
-  &lt;% end %&gt;
-  &lt;/p&gt;
-
-  &lt;p&gt;into: 
-  &lt;% if @scaffold_class.scaffold_use_auto_complete %&gt;
-    &lt;%= scaffold_text_field_tag_with_auto_complete('to', @scaffold_class) %&gt;
-  &lt;% else %&gt;
-    &lt;%= select_tag('to', &quot;&lt;option value=''&gt;&amp;nbsp;&lt;/option&gt;&quot;+options_from_collection_for_select(@scaffold_plural_object, :id, :scaffold_name)) %&gt;
-  &lt;% end %&gt;
-  &lt;/p&gt;
+&lt;%= scaffold_form(scaffold_url(&quot;merge_update#{@scaffold_suffix}&quot;)) %&gt;
+&lt;p&gt;Merge:
+&lt;% if @scaffold_class.scaffold_use_auto_complete %&gt;
+  &lt;%= scaffold_text_field_tag_with_auto_complete('from', @scaffold_options[:singular_name]) %&gt;
+&lt;% else %&gt;
+  &lt;%= scaffold_select_tag('from', @scaffold_objects) %&gt;
+&lt;% end %&gt;
+&lt;/p&gt;
 
-  &lt;input type=&quot;submit&quot; value=&quot;Merge &lt;%= @scaffold_plural_name.humanize.downcase %&gt;&quot; /&gt;
+&lt;p&gt;into: 
+&lt;% if @scaffold_class.scaffold_use_auto_complete %&gt;
+  &lt;%= scaffold_text_field_tag_with_auto_complete('to', @scaffold_options[:singular_name]) %&gt;
+&lt;% else %&gt;
+  &lt;%= scaffold_select_tag('to', @scaffold_objects) %&gt;
 &lt;% end %&gt;
+&lt;/p&gt;
+
+&lt;input type=&quot;submit&quot; value=&quot;Merge &lt;%= @scaffold_options[:plural_lc_human_name] %&gt;&quot; /&gt;
+&lt;/form&gt;
 
-&lt;%= manage_link %&gt;
+&lt;%= scaffold_manage_link %&gt;</diff>
      <filename>scaffolds/merge.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
-&lt;h1&gt;Create new &lt;%= @scaffold_singular_name.humanize.downcase %&gt;&lt;/h1&gt;
+&lt;% @scaffold_title = &quot;Create new #{@scaffold_options[:singular_lc_human_name]}&quot; %&gt;
 
-&lt;%= scaffold_form('create', :fields=&gt;@scaffold_class.scaffold_new_fields) %&gt;
+&lt;%= scaffold_model_form('create', @scaffold_class.scaffold_fields(:new)) %&gt;
 
-&lt;%= manage_link %&gt;
+&lt;%= scaffold_manage_link %&gt;</diff>
      <filename>scaffolds/new.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,11 @@
-&lt;h1&gt;Search for &lt;%= @scaffold_plural_name.humanize.downcase %&gt;&lt;/h1&gt;
+&lt;% @scaffold_title = &quot;Search #{@scaffold_options[:plural_lc_human_name]}&quot; %&gt;
 
-&lt;%= form(@scaffold_singular_name, :action=&gt;&quot;results&quot;+@scaffold_suffix, :submit_value=&gt;&quot;Search #{@scaffold_plural_name.humanize.downcase}&quot;, :fields=&gt;@scaffold_class.scaffold_search_fields) do |form|
-  form &lt;&lt; &quot;&lt;table class='#{@scaffold_class.scaffold_table_class :form}'&gt;&lt;tbody&gt;&quot;
-  form &lt;&lt; &quot;&lt;tr&gt;&lt;td&gt;Null Fields:&lt;/td&gt;&lt;td&gt;#{select('null', nil, @scaffold_class.scaffold_search_null_options, {}, :multiple=&gt;true)}&lt;/td&gt;&lt;/tr&gt;\n&quot;
-  form &lt;&lt; &quot;&lt;tr&gt;&lt;td&gt;Not Null Fields:&lt;/td&gt;&lt;td&gt;#{select('notnull', nil, @scaffold_class.scaffold_search_null_options, {}, :multiple=&gt;true)}&lt;/td&gt;&lt;/tr&gt;\n&quot;
+&lt;%= scaffold_model_form('results', @scaffold_class.scaffold_fields(:search)) do |form|
+  form &lt;&lt; &quot;&lt;table class='#{@scaffold_class.scaffold_table_class(:form)}'&gt;&lt;tbody&gt;&quot;
+  form &lt;&lt; &quot;&lt;tr&gt;&lt;td&gt;&lt;label for='null'&gt;Null Fields&lt;/label&gt;:&lt;/td&gt;&lt;td&gt;&lt;select name='null#{scaffold_param_list_suffix}' id='null' multiple='multiple'&gt;#{@scaffold_class.scaffold_search_null_options.collect{|name, i| &quot;&lt;option value='#{i}'&gt;#{name}&lt;/option&gt;&quot;}.join(&quot;\n&quot;)}&lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;\n&quot;
+  form &lt;&lt; &quot;&lt;tr&gt;&lt;td&gt;&lt;label for='notnull'&gt;Not Null Fields&lt;/label&gt;:&lt;/td&gt;&lt;td&gt;&lt;select name='notnull#{scaffold_param_list_suffix}' id='notnull' multiple='multiple'&gt;#{@scaffold_class.scaffold_search_null_options.collect{|name, i| &quot;&lt;option value='#{i}'&gt;#{name}&lt;/option&gt;&quot;}.join(&quot;\n&quot;)}&lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;\n&quot;
   form &lt;&lt; '&lt;/tbody&gt;&lt;/table&gt;'
+  @scaffold_submit_value = @scaffold_title
 end %&gt;
 
-&lt;%= manage_link %&gt;
+&lt;%= scaffold_manage_link %&gt;</diff>
      <filename>scaffolds/search.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,16 +1,19 @@
-&lt;h1&gt;Showing &lt;%= @scaffold_singular_name.humanize.downcase %&gt; &lt;%= link_to_or_blank('(edit)', :action=&gt;&quot;edit_#{@scaffold_class.name.underscore}&quot;, :id=&gt;@scaffold_singular_object.id) %&gt;&lt;/h1&gt;
+&lt;% @scaffold_title = &quot;Showing #{@scaffold_options[:singular_lc_human_name]}&quot; %&gt;
+&lt;% if '' != (edit_link = scaffold_check_link('Edit', true, &quot;edit_#{@scaffold_options[:singular_name]}&quot;, :id=&gt;@scaffold_object.scaffold_id)) %&gt;
+  &lt;h2&gt;&lt;%= edit_link %&gt;&lt;/h2&gt;
+&lt;% end %&gt;
 
-&lt;table id=&quot;scaffolded&quot; class=&quot;&lt;%= @scaffold_class.scaffold_table_class :show %&gt;&quot;&gt;
+&lt;table id=&quot;scaffolded&quot; class=&quot;&lt;%= @scaffold_class.scaffold_table_class(:show) %&gt;&quot;&gt;
 &lt;thead&gt;&lt;tr&gt;&lt;th&gt;Attribute&lt;/th&gt;&lt;th&gt;Value&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;
 &lt;tbody&gt;
-&lt;% @scaffold_class.scaffold_show_fields.each do |column| %&gt;
+&lt;% @scaffold_class.scaffold_fields(:show).each do |column| %&gt;
   &lt;tr&gt;
     &lt;td&gt;&lt;%= @scaffold_class.scaffold_column_name(column) %&gt;&lt;/td&gt;
-    &lt;td&gt;&lt;%=h scaffold_value(@scaffold_singular_object, column) %&gt;&lt;/td&gt;
+    &lt;td&gt;&lt;%=h @scaffold_object.scaffold_value(column).to_s %&gt;&lt;/td&gt;
   &lt;/tr&gt;
 &lt;% end %&gt;
 &lt;/tbody&gt;&lt;/table&gt;
 
-&lt;%= association_links %&gt;
+&lt;%= scaffold_association_links %&gt;
 
-&lt;%= manage_link %&gt;
+&lt;%= scaffold_manage_link %&gt;</diff>
      <filename>scaffolds/show.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,44 +1,44 @@
 require 'test/unit'
 
-# Functions have been added to test the scaffold and scaffold_all_models method
+# Simple test framework to check that public facing pages without an id respond successfully
+#
+# This is only a basic check, it does not check that all form submittals work, as that
+# requires that you choose an object to test.  If you want to be sure that all parts of
+# Scaffolding Extensions work with your applications, you should extend the tests here to do so.
 class Test::Unit::TestCase
   # Test the scaffold_all_models method using the same arguments as the method
-  def self.test_scaffold_all_models(*models)
-    ActionController::Base.parse_scaffold_all_models_options(*models).each do |model, options|
-      test_scaffold(model, options)
-    end
+  def self.test_scaffold_all_models(options = {})
+    ActionController::Base.send(:scaffold_all_models_parse_options, options).each{|model, options| test_scaffold(model, options)}
   end
   
   # Test the scaffold method using the same arguments as the method
   def self.test_scaffold(model, options = {})
-    define_method(&quot;test_scaffold_#{model}&quot;) { scaffold_test(model, options) }
+    define_method(&quot;test_scaffold_#{model.scaffold_name}&quot;){scaffold_test(model, options)}
   end
 
   # Test that getting all display actions for the scaffold returns success
   def scaffold_test(model, options = {})
-    methods = options[:only] ? @controller.class.normalize_scaffold_options(options[:only]) : @controller.class.default_scaffold_methods
-    methods -= @controller.class.normalize_scaffold_options(options[:except]) if options[:except]
+    klass = @controller.class
+    methods = options[:only] ? klass.scaffold_normalize_options(options[:only]) : ScaffoldingExtensions::DEFAULT_METHODS
+    methods -= klass.scaffold_normalize_options(options[:except]) if options[:except]
     methods.each do |action|
-      assert_nothing_raised(&quot;Error requesting scaffolded action #{action} for model #{model.to_s.camelize}&quot;) do
-        action = &quot;#{action}_#{model}&quot; if options[:suffix]
-        get action
+      assert_nothing_raised(&quot;Error requesting scaffolded action #{action} for model #{model.name}&quot;) do
+        get &quot;#{action}_#{model.scaffold_name}&quot;
       end
-      assert_response :success, &quot;Response for scaffolded action #{action} for model #{model.to_s.camelize} not :success&quot;
+      assert_response :success, &quot;Response for scaffolded action #{action} for model #{model.name} not :success&quot;
       # # The habtm scaffolds can't be tested without an id.  If the fixture for the
       # # main scaffolded class is loaded and it has id = 1, you may want to enable
       # # the following code for testing those scaffolds.
-      # @controller.class.normalize_scaffold_options(options[:habtm]).each do |habtm|
-      #   scaffold_habtm_test(model, habtm, 1)
+      # model.scaffold_habtm_associations.each do |association|
+      #   scaffold_habtm_test(model, association, 1)
       # end
     end
   end
   
   # Test the habtm scaffold for singular class, many class, and the specific id
-  def scaffold_habtm_test(singular, many, id)
-    action = &quot;edit_#{singular}_#{many}&quot;, {:id=&gt;id}
-    assert_nothing_raised(&quot;Error requesting habtm scaffold #{action}&quot;) do
-      get action
-    end
+  def scaffold_habtm_test(model, association, id)
+    action = &quot;edit_#{model.scaffold_name}_#{association}&quot;, {:id=&gt;id}
+    assert_nothing_raised(&quot;Error requesting habtm scaffold #{action}&quot;){get action}
     assert_response :success, &quot;Response for habtm scaffold #{action} not :success&quot;
   end
 end</diff>
      <filename>test/scaffolding_extensions_test.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>contrib/scaffold_auto_complete_without_association/README</filename>
    </removed>
    <removed>
      <filename>contrib/scaffold_auto_complete_without_association/scaffolding_extensions.rb.patch</filename>
    </removed>
    <removed>
      <filename>contrib/scaffold_select_typeahead/README</filename>
    </removed>
    <removed>
      <filename>contrib/scaffold_select_typeahead/scaffolding_extensions.rb.patch</filename>
    </removed>
    <removed>
      <filename>contrib/scaffold_select_typeahead/select.js</filename>
    </removed>
    <removed>
      <filename>scaffolds/associations.rhtml</filename>
    </removed>
    <removed>
      <filename>scaffolds/habtm_ajax.rhtml</filename>
    </removed>
    <removed>
      <filename>tasks/scaffolding_extensions_tasks.rake</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>0b237494d71d4ba07de72fd1b699385f5a739d7a</id>
    </parent>
  </parents>
  <author>
    <name>Jeremy Evans</name>
    <email>code@jeremyevans.net</email>
  </author>
  <url>http://github.com/jeremyevans/scaffolding_extensions/commit/ad9ae3a65b324521c5f3c6e2ef33d4533ecc2a01</url>
  <id>ad9ae3a65b324521c5f3c6e2ef33d4533ecc2a01</id>
  <committed-date>2008-02-11T15:44:25-08:00</committed-date>
  <authored-date>2008-02-11T15:44:25-08:00</authored-date>
  <message>Rewrote/refactored most of the code, making it more modular and able to support multiple web frameworks and ORMs
Add support for the Ramaze web framework
Remove scaffold_auto_complete_without_association and scaffold_select_typeahead contributions, since the patches no longer apply
Remove the habtm_ajax and associations scaffolds, as those are now handled as inline templates
Remove the tasks directory, as it was never used
Remove the test task from the Rakefile, and make rdoc generation the default task
Bump the copyright date to 2008
Add a doc directory with a bunch of useful text files</message>
  <tree>61a698afd7fe8d1476301767eeeab5f858b4277e</tree>
  <committer>
    <name>Jeremy Evans</name>
    <email>code@jeremyevans.net</email>
  </committer>
</commit>
