Script.aculo.us helpers "drop_receiving_element" and "sortable_element" broken in Rails 2.1.0
Reported by Mark Myers | June 22nd, 2008 @ 08:05 PM
Script.aculo.us helpers "drop_receiving_element" and
"sortable_element" calling against a nil object and returning a
NoMethodError exception.
I have tested this same code on Rails 1.2.6 and it works successfully.
Example view code 1:
<%= draggable_element :dragit %>
<%= drop_receiving_element :dropHelperDIV, :hoverclass => 'hover' %>
Error "NoMethodError":
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.[]
Application Trace:
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
url_rewriter.rb:102:in `rewrite_url'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
url_rewriter.rb:88:in `rewrite'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:621:in `url_for'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/
url_helper.rb:76:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/
url_helper.rb:76:in `url_for'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/
prototype_helper.rb:461:in `remote_function'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/
scriptaculous_helper.rb:212:in `drop_receiving_element_js'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/
scriptaculous_helper.rb:207:in `drop_receiving_element'
app/views/chapter4/draggables.html.erb:5:in
`_run_erb_47app47views47chapter447draggables46html46erb'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/base.rb:
338:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/base.rb:
338:in `execute'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/
template_handlers/compilable.rb:29:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/
template_handlers/compilable.rb:29:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/
template.rb:35:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/
template.rb:22:in `render_template'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/base.rb:
245:in `render_file'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:1108:in `render_for_file'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:841:in `render_with_no_layout'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
layout.rb:251:in `render_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:51:in `render'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
core_ext/benchmark.rb:8:in `realtime'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:51:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:1157:in `default_render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:1168:in `perform_action_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:580:in `call_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:573:in `perform_action_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
rescue.rb:201:in `perform_action_without_caching'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
caching/sql_cache.rb:13:in `perform_action'
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/
connection_adapters/abstract/query_cache.rb:33:in `cache'
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/
query_cache.rb:8:in `cache'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
caching/sql_cache.rb:12:in `perform_action'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:529:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:529:in `process_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:569:in `process_without_session_management_support'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
session_management.rb:130:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:389:in `process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in
`process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in
`synchronize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in
`process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:
282:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:
281:in `each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:
281:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:
212:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:354:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
/Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/commands/servers/
mongrel.rb:64
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:509:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:354:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:509:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39
-------------------------------------------------------------------------------------------------------------------------------------
Example view code 2:
- x Buy milk
- x Take out trash
- x Make first million
<%= sortable_element :listHandle, :handle => 'handle' %>
Error "NoMethodError":
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.[]
Application Trace:
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
url_rewriter.rb:102:in `rewrite_url'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
url_rewriter.rb:88:in `rewrite'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:621:in `url_for'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/
url_helper.rb:76:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/
url_helper.rb:76:in `url_for'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/
prototype_helper.rb:461:in `remote_function'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/
scriptaculous_helper.rb:141:in `sortable_element_js'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/helpers/
scriptaculous_helper.rb:136:in `sortable_element'
app/views/chapter4/draggables.html.erb:7:in
`_run_erb_47app47views47chapter447draggables46html46erb'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/base.rb:
338:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/base.rb:
338:in `execute'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/
template_handlers/compilable.rb:29:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/
template_handlers/compilable.rb:29:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/
template.rb:35:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/
template.rb:22:in `render_template'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_view/base.rb:
245:in `render_file'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:1108:in `render_for_file'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:841:in `render_with_no_layout'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
layout.rb:251:in `render_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:51:in `render'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
core_ext/benchmark.rb:8:in `realtime'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:51:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:1157:in `default_render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:1168:in `perform_action_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:580:in `call_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:573:in `perform_action_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
rescue.rb:201:in `perform_action_without_caching'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
caching/sql_cache.rb:13:in `perform_action'
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/
connection_adapters/abstract/query_cache.rb:33:in `cache'
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/
query_cache.rb:8:in `cache'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
caching/sql_cache.rb:12:in `perform_action'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:529:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:529:in `process_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
filters.rb:569:in `process_without_session_management_support'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
session_management.rb:130:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/
base.rb:389:in `process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in
`process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in
`synchronize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in
`process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:
282:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:
281:in `each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:
281:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:
212:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:354:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:502:in `load'
/Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/commands/servers/
mongrel.rb:64
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:509:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:354:in `new_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/
dependencies.rb:509:in `require'
/Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39
Comments and changes to this ticket
-

-

Bill Coomer July 7th, 2008 @ 04:12 PM
- → Tag cleared.
I have essentially the same problem. If I do the following in a view:
Drop Here<%= drop_receiving_element_js :dropTest, :hoverclass => "hover" %>
I get the
"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.[]"
error. I can create this error consistently using Rails 2.1.0, ruby 1.8.6 or 1.8.5, running on a win32 platform using mongrel.
-

deliverator August 3rd, 2008 @ 11:58 PM
Same problem using rails 2.1.0 with mongrel on OS X 10.5.4, Ruby 1.8.6 (2008-03-03 patchlevel 114)...
And also using rails 2.1.0 with mongrel on Gentoo with ruby 1.8.6 (2008-03-03 patchlevel 114).
-
Dieter Komendera August 4th, 2008 @ 07:10 AM
This seems to be already fixed by commit 96708af6a58a48c2324a3bf8d34232bc29b398c9: http://github.com/rails/rails/co...
-
Joshua Peek November 10th, 2008 @ 06:51 PM
- → State changed from new to resolved
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Source available from github
Repository is at http://github.com/rails/rails
Check out the development master (Edge Rails):
git clone git://github.com/rails/rails.git
Creating or reviewing a patch
See the contributor guide.
Creating a feature request
Please don't. If you want a new feature in Rails, you'll have to pull up your sleeves and get busy yourself. Or convince someone else to do it. See the contributor guide on how to get going. But posting them here is just going to lead to ticket root.
Creating a bug report
When creating a bug report, be sure to include as much relevant information as possible. Post the code sample that causes the problem. Preferably, alter the unit tests and show through either changed or added tests how the expected behavior is not occuring.
Security vulnerabilities should be reported via an email to security@rubyonrails.org, do not use trac for reporting security vulnerabilities. All content in trac is publicly available as soon as it is posted.
Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kinda bug, you're creating this ticket in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the ticket automatically will see any activity or that others will jump to fix it. Creating a ticket like this is mostly to help yourself start on the path of fixing the problem and for others to sign on to with a "I'm having this problem too"..
