aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/prototype_helper.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-03-05 06:42:58 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-03-05 06:42:58 +0000
commit16b9409a9c087d26e415de9fe66b8a754d76e7f0 (patch)
treee597e18fd2a5518ed717749077c216a748945787 /actionpack/lib/action_view/helpers/prototype_helper.rb
parent5afbffdd95c738f33f41efc0a42af1b73ad4dfe4 (diff)
downloadrails-16b9409a9c087d26e415de9fe66b8a754d76e7f0.tar.gz
rails-16b9409a9c087d26e415de9fe66b8a754d76e7f0.tar.bz2
rails-16b9409a9c087d26e415de9fe66b8a754d76e7f0.zip
allow RJS enum values to be passed to visual_effect() and other scriptaculous helpers #4080 [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3772 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/prototype_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index db36f3de5f..9a58f41821 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -409,7 +409,8 @@ module ActionView
class JavaScriptGenerator
def initialize(context, &block) #:nodoc:
@context, @lines = context, []
- include_helpers_from_context
+ # removed because those methods were overriding valid generator methods
+ # include_helpers_from_context
@context.instance_exec(self, &block)
end
@@ -567,7 +568,7 @@ module ActionView
# Starts a script.aculo.us visual effect. See
# ActionView::Helpers::ScriptaculousHelper for more information.
- def visual_effect(name, id, options = {})
+ def visual_effect(name, id = nil, options = {})
record @context.send(:visual_effect, name, id, options)
end
@@ -791,7 +792,7 @@ module ActionView
append_enumerable_function!("zip(#{arguments.collect { |a| a.to_json } * ', '}")
if block
function_chain[-1] += ", function(array) {"
- yield @generator, ActiveSupport::JSON::Variable.new('array')
+ yield ActiveSupport::JSON::Variable.new('array')
add_return_statement!
@generator << '});'
else
@@ -811,7 +812,8 @@ module ActionView
def enumerable_method(enumerable, variable, yield_params, &block)
add_variable_assignment!(variable) if variable
append_enumerable_function!(enumerable)
- yield *([@generator] + yield_params.collect { |p| JavaScriptVariableProxy.new(@generator, p) })
+ # only yield as many params as were passed in the block
+ yield *yield_params.collect { |p| JavaScriptVariableProxy.new(@generator, p) }[0..block.arity-1]
add_return_statement! if variable
@generator << '});'
end