I've fixed this issue for my application with the following diff. I borrowed the code changes from official active_scaffold.
You can see the change in my fork here: https://github.com/courtland/active_scaffold/commit/cdfb6d28c724e3d8d29e0ffafba00ad36d3de88f ~/git/active_scaffold_vho: git diff diff --git a/lib/active_scaffold/helpers/form_column_helpers.rb b/lib/active_scaffold/helpers/form_column_helpers.rb index f83e88f..44cae3b 100644 --- a/lib/active_scaffold/helpers/form_column_helpers.rb +++ b/lib/active_scaffold/helpers/form_column_helpers.rb @@ -244,8 +244,7 @@ module ActiveScaffold # add functionality for overriding subform partials from association class path def override_subform_partial?(column, subform_partial) - path, partial_name = partial_pieces(override_subform_partial(column, subform_partial)) - template_exists?(partial_name, path) + template_exists?(override_subform_partial(column, subform_partial), true) end def override_subform_partial(column, subform_partial) @@ -253,22 +252,26 @@ module ActiveScaffold end def override_form_field_partial?(column) - path, partial_name = partial_pieces(override_form_field_partial(column)) - template_exists?(partial_name, path) + template_exists?(override_form_field_partial(column), true) end # the naming convention for overriding form fields with partials def override_form_field_partial(column) - "#{column.name}_form_column" + path = active_scaffold_controller_for(column.active_record_class).controller_path + File.join(path, "#{clean_column_name(column.name)}_form_column") end - def override_form_field?(column) - respond_to?(override_form_field(column)) + def override_form_field(column) + method_with_class = override_form_field_name(column, true) + return method_with_class if respond_to?(method_with_class) + method = override_form_field_name(column) + method if respond_to?(method) end + alias_method :override_form_field?, :override_form_field # the naming convention for overriding form fields with helpers - def override_form_field(column) - "#{column.name}_form_column" + def override_form_field_name(column, class_prefix = false) + "#{clean_class_name(column.active_record_class.name) + '_' if class_prefix}#{clean_column_name(column.name)}_form_column" end def override_input?(form_ui) diff --git a/lib/active_scaffold/helpers/view_helpers.rb b/lib/active_scaffold/helpers/view_helpers.rb index 3520b34..641db1a 100755 --- a/lib/active_scaffold/helpers/view_helpers.rb +++ b/lib/active_scaffold/helpers/view_helpers.rb @@ -42,26 +42,10 @@ module ActiveScaffold end ~/git/active_scaffold_vho: git diff > ../patch ~/git/active_scaffold_vho: cat ../patch diff --git a/lib/active_scaffold/helpers/form_column_helpers.rb b/lib/active_scaffold/helpers/form_column_helpers.rb index f83e88f..44cae3b 100644 --- a/lib/active_scaffold/helpers/form_column_helpers.rb +++ b/lib/active_scaffold/helpers/form_column_helpers.rb @@ -244,8 +244,7 @@ module ActiveScaffold # add functionality for overriding subform partials from association class path def override_subform_partial?(column, subform_partial) - path, partial_name = partial_pieces(override_subform_partial(column, subform_partial)) - template_exists?(partial_name, path) + template_exists?(override_subform_partial(column, subform_partial), true) end def override_subform_partial(column, subform_partial) @@ -253,22 +252,26 @@ module ActiveScaffold end def override_form_field_partial?(column) - path, partial_name = partial_pieces(override_form_field_partial(column)) - template_exists?(partial_name, path) + template_exists?(override_form_field_partial(column), true) end # the naming convention for overriding form fields with partials def override_form_field_partial(column) - "#{column.name}_form_column" + path = active_scaffold_controller_for(column.active_record_class).controller_path + File.join(path, "#{clean_column_name(column.name)}_form_column") end - def override_form_field?(column) - respond_to?(override_form_field(column)) + def override_form_field(column) + method_with_class = override_form_field_name(column, true) + return method_with_class if respond_to?(method_with_class) + method = override_form_field_name(column) + method if respond_to?(method) end + alias_method :override_form_field?, :override_form_field # the naming convention for overriding form fields with helpers - def override_form_field(column) - "#{column.name}_form_column" + def override_form_field_name(column, class_prefix = false) + "#{clean_class_name(column.active_record_class.name) + '_' if class_prefix}#{clean_column_name(column.name)}_form_column" end def override_input?(form_ui) diff --git a/lib/active_scaffold/helpers/view_helpers.rb b/lib/active_scaffold/helpers/view_helpers.rb index 3520b34..641db1a 100755 --- a/lib/active_scaffold/helpers/view_helpers.rb +++ b/lib/active_scaffold/helpers/view_helpers.rb @@ -42,26 +42,10 @@ module ActiveScaffold end end - def partial_pieces(partial_path) - if partial_path.include?('/') - return File.dirname(partial_path), File.basename(partial_path) - else - return controller.class.controller_path, partial_path - end - end - # This is the template finder logic, keep it updated with however we find stuff in rails # currently this very similar to the logic in ActionBase::Base.render for options file - # TODO: Work with rails core team to find a better way to check for this. - # Not working so far for rais 3.1 - def template_exists?(template_name, path) - begin - method = 'find_template' - #self.view_paths.send(method, template_name) - return false - rescue ActionView::MissingTemplate => e - return false - end + def template_exists?(template_name, partial = false) + lookup_context.exists? template_name, '', partial end def generate_temporary_id @@ -338,6 +322,14 @@ module ActiveScaffold value end + def clean_column_name(name) + name.to_s.gsub('?', '') + end + + def clean_class_name(name) + name.underscore.gsub('/', '_') + end + def active_scaffold_error_messages_for(*params) options = params.extract_options!.symbolize_keys options.reverse_merge!(:container_tag => :div, :list_type => :ul) On Thu, Jan 12, 2012 at 9:49 AM, Nick Rogers <[email protected]> wrote: > Form overrides no longer work in active_scaffold_vho master branch under > rails 3.1.3. These used to work for me in the rails-3 branch and appear to > still work in the official active_scaffold master branch. > > As explained here: > https://github.com/activescaffold/active_scaffold/wiki/Form-Overrides > > I have a number of *_form_column.html.erb partials that are not rendered. > > Thanks. > > -Nick > -- You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en.
