Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 'need_tag' as option name to prevent calling 'tag' method #190

Merged
merged 1 commit into from
Jul 30, 2015
Merged

Use 'need_tag' as option name to prevent calling 'tag' method #190

merged 1 commit into from
Jul 30, 2015

Conversation

june29
Copy link
Contributor

@june29 june29 commented Jul 30, 2015

I try to use gon v6.0.1 with Rails v4.2.3. In my app, I met following error:

ActionView::Template::Error: wrong number of arguments (0 for 1..4)
    /Users/june29/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/actionview-4.2.3/lib/action_view/helpers/tag_helper.rb:74:in `tag'
    /Users/june29/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/gon-6.0.1/lib/gon/base.rb:26:in `render_data'
    /Users/june29/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/gon-6.0.1/lib/gon/helpers.rb:5:in `include_gon'
    /Users/june29/path/to/myapp/app/views/layouts/application.html.erb:29:in
...

The code _o.tag on this line calls tag method defined in ActionView.

script = Gon::Escaper.javascript_tag(script, _o.type, _o.cdata, _o.nonce) if _o.tag

So I want to rename option tag to solve this problem.

gazay added a commit that referenced this pull request Jul 30, 2015
…g-tag-method

Use 'need_tag' as option name to prevent calling 'tag' method
@gazay gazay merged commit 76a6810 into gazay:master Jul 30, 2015
@gazay
Copy link
Owner

gazay commented Jul 30, 2015

Great, Thank you!

@gazay
Copy link
Owner

gazay commented Jul 30, 2015

I just not really understand why it happening? _o is an OpenStruct object, and don't have methods from ActionView

@june29
Copy link
Contributor Author

june29 commented Jul 30, 2015

Thank you for your response!

Can you see this problem on your environment? If you can, please try it.

@june29 june29 deleted the rename-variable-to-prevent-calling-tag-method branch July 30, 2015 06:31
@gazay
Copy link
Owner

gazay commented Jul 30, 2015

We're using gon in our projects and I didn't see this problem after update. Anyway it's good to rename just to need_tag as tag option was excess. Can you provide full backtrace of error?

@june29
Copy link
Contributor Author

june29 commented Jul 30, 2015

Oh, I found out a new fact. In our Rails app context, OpenStruct class includes some Modules.

pry(Gon::Base)> OpenStruct.ancestors
=> [OpenStruct,
 Object,
 Sprockets::Rails::Helper,
 ActionView::Helpers::AssetTagHelper,
 ActionView::Helpers::TagHelper,
 ActionView::Helpers::OutputSafetyHelper,
 ActionView::Helpers::CaptureHelper,
 ActionView::Helpers::AssetUrlHelper,
 Minitest::Expectations,
 Metaclass::ObjectMethods,
 Mocha::ObjectMethods,
 PP::ObjectMixin,
 Delayed::MessageSending,
 ActiveSupport::Dependencies::Loadable,
 JSON::Ext::Generator::GeneratorMethods::Object,
 Kernel,
 BasicObject]

@gazay
Copy link
Owner

gazay commented Jul 30, 2015

I see. Anyway it is a good pull request, thank you =)

@june29
Copy link
Contributor Author

june29 commented Jul 30, 2015

Thank you merging 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants