> I believe the reasoning behind saying that the plugin is not yet compatible
> with Rails 2.1 is because it was compatible with Rails 2.0, therefore it has
> not been maintained.
>
> If you get it working with Rails 2.2 let me know.
Turns out that the primary problem seems to be restricted to the view
path, and the following patch resolves it. Note that I didn't remove
the old code so that it will still work with Rails < 2.2.
diff --git a/lib/actions/sortable.rb b/lib/actions/sortable.rb
index 669a369..7ba6a61 100644
--- a/lib/actions/sortable.rb
+++ b/lib/actions/sortable.rb
@@ -15,6 +15,8 @@ module ActiveScaffold::Actions
if base.respond_to?(:generic_view_paths) && ! base.generic_view_paths.empty?
base.generic_view_paths.insert(0, sortable_plugin_path)
+ elsif base.respond_to?(:view_paths)
+ base.prepend_view_path(sortable_plugin_path)
else
config.inherited_view_paths << sortable_plugin_path
end
A secondary problem is with the RESTful route generation which is fixed
with the following patch. I don't know if it's a change from 2.0 or
something odd in my setup, but the original member route generation just
does not work and it doesn't make sense to me to reference
/controller/:id/reorder since you're reordering the whole collection.
diff --git a/lib/extensions/resources.rb b/lib/extensions/resources.rb
index c33cd24..34c5390 100644
--- a/lib/extensions/resources.rb
+++ b/lib/extensions/resources.rb
@@ -5,8 +5,8 @@ module ActionController
def options_with_as_sortable
if @options.delete(:active_scaffold_sortable)
logger.info "active_scaffold_sortable: extending RESTful routes for #{@plural}"
- @options[:member] ||= {}
- @options[:member].merge!(:reorder => :post)
+ @options[:collection] ||= {}
+ @options[:collection].merge!(:reorder => :post)
end
options_without_as_sortable
end
After applying both patches, ActiveScaffoldSortable is working for me in
in both a 2.1 and a 2.2 environment (I have not tested edge or anything
earlier than 2.1).