I want to create a sortable_element which doesn't send an AJAX
request onUpdate.
However, if the :url option is not included, then rails returns
an error:
You have a nil object when you didn't expect it! You might have
expected an instance of ActiveRecord::Base. The error occurred
while evaluating nil.[]
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/url_rewriter.rb:95:in
rewrite_url'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/url_rewriter.rb:81:inrewrite'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/base.rb:616:in
url_for'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/url_helper.rb:76:insend'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/url_helper.rb:76:in
url_for'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/prototype_helper.rb:461:inremote_function'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/scriptaculous_helper.rb:144:in
sortable_element_js'
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/scriptaculous_helper.rb:139:insortable_element'
app/views/photos/index.html.erb:34:in
_run_erb_47app47views47photos47index46html46erb'
app/controllers/photos_controller.rb:58:inindex' -e:2:in
load' -e:2
The solution I've found is to change like 144 of
scriptaculous_helper from:
options[:onUpdate] ||= "function(){" + remote_function(options)
+ "}"
to
options[:onUpdate] ||= "function(){" + remote_function(options)
+ "}" unless options[:url].nil?
But I don't know if this will fix the problem in all cases.