Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

sortable_element with no :url option

#1009

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.

Reported by Hang · September 10th, 2008 @ 02:33 AM

State: stale
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Emilio Tagua
    Emilio Tagua

    If you want to send a patch, start by reading this:

    http://rails.lighthouseapp.com/p...

    About fixing the problem in all cases, add tests proving your fix and run the current test suite for actionpack to be sure nothing has been broken.

    Good luck!

    September 12th, 2008 @ 02:50 PM

  2. josh
    josh
    • State changed from new to incomplete

    December 20th, 2008 @ 05:19 PM

  3. Ryan Bigg
    Ryan Bigg
    • State changed from incomplete to stale

    If anybody still wants this functionality please discuss the point further.

    April 11th, 2010 @ 12:01 AM