This project is archived and is in readonly mode.

#1009 ✓stale
Hang

sortable_element with no :url option

Reported by Hang | September 10th, 2008 @ 02:33 AM | in 2.x

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.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages