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

form_for - Duplicate option tags generated for select tag #201

Open
jiggneshhgohel opened this issue May 18, 2023 · 0 comments
Open

form_for - Duplicate option tags generated for select tag #201

jiggneshhgohel opened this issue May 18, 2023 · 0 comments

Comments

@jiggneshhgohel
Copy link

jiggneshhgohel commented May 18, 2023

Ruby 3.1.2

Gemfile

gem "hanami", "~> 2.0"
gem "hanami-router", "~> 2.0"
gem "hanami-controller", "~> 2.0"
gem "hanami-validations", "~> 2.0"

gem 'hanami-view', github: "hanami/view", ref: '35a90c2517e0e636e6577c0bcf752bf6a70a9694'

# TODO: Temporary using the `main` branch because using the released version `1.3.3` causes conflict of `hanami-utils` version ( hanami-utils (~> 1.3) ) used by `hanami-controller` version ( hanami-utils (~> 2.0) )
gem 'hanami-helpers', github: "hanami/helpers", branch: 'main'

gem 'hamlit', '~> 3.0', '>= 3.0.3'

Gemfile.lock

GIT
  remote: https://github.com/hanami/helpers.git
  revision: b9e8cf0fdc4599bd89cd374f43d56644c9e4054b
  branch: main
  specs:
    hanami-helpers (2.0.0.alpha1)
      hanami-utils (~> 2.0)

GIT
  remote: https://github.com/hanami/view.git
  revision: 35a90c2517e0e636e6577c0bcf752bf6a70a9694
  ref: 35a90c2517e0e636e6577c0bcf752bf6a70a9694
  specs:
    hanami-view (2.0.0.alpha8)
      concurrent-ruby (~> 1.0)
      dry-configurable (~> 1.0.0.rc)
      dry-core (~> 1.0.0.rc)
      dry-inflector (~> 1.0, < 2)
      tilt (~> 2.0, >= 2.0.6)

my_view.html.haml

In my view I have following code generating a form using form_for helper.

= form_for(form_name, form_url, method: form_method_option_value) do
  .form-control<
    = label('Name')
    = text_field(:name, value: nil)

  .form-control<
    = label('Select Language')
    
    - options = { lang_1: 'Language-1', lang_2: 'Language-2' }
    = select(:language, options)

When the page is rendered in the select tag generated I can seen duplicate options

<form action="TODO" method="POST" accept-charset="utf-8" id="my-entity-form">
<input type="hidden" name="_csrf_token" value="b2142aa129f36d229ac30ca394b648be9152134297284d95632eb848e777b470">
<label for="my-entity-term">Term</label>
<input type="text" name="my-entity[term]" id="my-entity-term" value="">
<label for="my-entity[select-language]">Select Language</label>
<select name="my-entity[language]" id="my-entity-language">
<option value="lang_1">Language-1</option>
<option value="lang_2">Language-2</option>
<option value="lang_1">Language-1</option>
<option value="lang_2">Language-2</option>
</select>
</form>

Experimenting with the code I figured out that the problem is with the helper methods prefixed with =.

Updating the view code in following manner the duplicate options problem is gone:

= form_for(form_name, form_url, method: form_method_option_value) do
  .form-control<
    - label('Name')
    - text_field(:name, value: nil)

  .form-control<
    - label('Select Language')
    
    - options = { lang_1: 'Language-1', lang_2: 'Language-2' }
    - select(:language, options)

But then it raised a question that if using = is the problem then the label and text-field tags should also have been duplicated but that isn't the case. So I tried to debug the source code and added following

  caller_locations(0..20).map do |call|
    puts call.to_s
  end

above values.each do |content, value| line in the block given to super(attributes) in following method:

def select(name, values, attributes = {})
options = attributes.delete(:options) { {} }
multiple = attributes[:multiple]
attributes = {name: _select_input_name(name, multiple), id: _input_id(name)}.merge(attributes)
prompt = options.delete(:prompt)
selected = options.delete(:selected)
input_value = _value(name)
super(attributes) do
option(prompt, disabled: true) if prompt
already_selected = nil
values.each do |content, value|
if (multiple || !already_selected) && (already_selected = _select_option_selected?(value, selected, input_value, multiple))
option(content, {value: value, selected: SELECTED}.merge(options))
else
option(content, {value: value}.merge(options))
end
end
end
end

and then refreshing the page I found following in the server logs:

/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:1313:in `block in select'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `instance_exec'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `resolve'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:60:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/html_node.rb:51:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:46:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `map'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:143:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:63:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/html_node.rb:51:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:46:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `map'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:143:in `to_s'
/home/jignesh/...../app/templates/...../my_view.html.haml:45:in `__tilt_7880'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `bind_call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `evaluate'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:109:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:49:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:32:in `template'

Above was found when used - before select(:language, options) in the view.

When used = before select(:language, options) in the view following was found:

/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:1313:in `block in select'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `instance_exec'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `resolve'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:60:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/html_node.rb:51:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:46:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `map'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:143:in `to_s'
/home/jignesh/...../app/templates/...../my_view.html.haml:45:in `block in __tilt_7880'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `instance_exec'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `resolve'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:60:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/html_node.rb:51:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:46:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `map'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:143:in `to_s'
/home/jignesh/...../app/templates/...../my_view.html.haml:45:in `__tilt_7880'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `bind_call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `evaluate'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:1313:in `block in select'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `instance_exec'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `resolve'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:60:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/html_node.rb:51:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:46:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `map'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:143:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:63:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/html_node.rb:51:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:46:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `map'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:143:in `to_s'
/home/jignesh/...../app/templates/...../my_view.html.haml:45:in `__tilt_7880'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `bind_call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `evaluate'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:109:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:49:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:32:in `template'

As can be seen in above case following duplicate calls can be seen:

/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `bind_call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `evaluate'

...
...
...

/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `bind_call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `evaluate'

So I found that it is the template's evaluate method duplicate invocation which is causing the behaviour. To be more sure about this conclusion of mine this time I printed the complete call-trace by changing

  caller_locations(0..20).map do |call|
    puts call.to_s
  end

to following

  caller_locations.map do |call|
    puts call.to_s
  end

and retaining = select(:language, options) in the view and I found following:

/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:1313:in `block in select'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `instance_exec'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `resolve'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:60:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/html_node.rb:51:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:46:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `map'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:143:in `to_s'
/home/jignesh/...../app/templates/...../my_view.html.haml:45:in `block in __tilt_7880'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `instance_exec'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `resolve'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:60:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/html_node.rb:51:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:46:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `map'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:143:in `to_s'
/home/jignesh/...../app/templates/...../my_view.html.haml:45:in `__tilt_7880'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `bind_call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `evaluate'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:109:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:49:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:32:in `template'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:39:in `partial'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/render_environment.rb:48:in `partial'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/scope.rb:99:in `render'
/home/jignesh/...../app/templates/...../new.html.haml:5:in `__tilt_7880'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `bind_call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `evaluate'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:109:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:49:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:32:in `template'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/render_environment.rb:44:in `template'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view.rb:568:in `call'
/home/jignesh/..../app/view/base.rb:21:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-controller-2.0.2/lib/hanami/action/response.rb:109:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-2.0.3/lib/hanami/extensions/action.rb:92:in `finish'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-controller-2.0.2/lib/hanami/action/session.rb:43:in `finish'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-controller-2.0.2/lib/hanami/action/cookies.rb:23:in `finish'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-controller-2.0.2/lib/hanami/action.rb:332:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-2.0.3/lib/hanami/slice/routing/resolver.rb:78:in `block in resolve_slice_action'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-router-2.0.2/lib/hanami/router.rb:108:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/rack-2.2.7/lib/rack/method_override.rb:24:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/rack-2.2.7/lib/rack/session/abstract/id.rb:266:in `context'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/rack-2.2.7/lib/rack/session/abstract/id.rb:260:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/dry-monitor-1.0.1/lib/dry/monitor/rack/middleware.rb:36:in `block in call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/dry-monitor-1.0.1/lib/dry/monitor/clock.rb:15:in `measure'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/dry-monitor-1.0.1/lib/dry/monitor/rack/middleware.rb:36:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-router-2.0.2/lib/hanami/middleware/app.rb:40:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-2.0.3/lib/hanami/slice.rb:758:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/rack-2.2.7/lib/rack/static.rb:161:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/configuration.rb:270:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/request.rb:98:in `block in handle_request'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/request.rb:97:in `handle_request'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/server.rb:431:in `process_client'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/server.rb:233:in `block in run'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/thread_pool.rb:147:in `block in spawn_thread'


/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:1313:in `block in select'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `instance_exec'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:377:in `resolve'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:60:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/html_node.rb:51:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:46:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `map'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:143:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:63:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/html_node.rb:51:in `content'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_node.rb:46:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `map'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/html_helper/html_builder.rb:336:in `to_s'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/helpers-b9e8cf0fdc45/lib/hanami/helpers/form_helper/form_builder.rb:143:in `to_s'
/home/jignesh/...../app/templates/...../my_view.html.haml:45:in `__tilt_7880'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `bind_call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `evaluate'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:109:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:49:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:32:in `template'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:39:in `partial'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/render_environment.rb:48:in `partial'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/scope.rb:99:in `render'
/home/jignesh/...../app/templates/...../new.html.haml:5:in  `__tilt_7880'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `bind_call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:191:in `evaluate'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/tilt-2.1.0/lib/tilt/template.rb:109:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:49:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/renderer.rb:32:in `template'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view/render_environment.rb:44:in `template'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view.rb:568:in `call'
/home/jignesh/..../app/view/base.rb:21:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-controller-2.0.2/lib/hanami/action/response.rb:109:in `render'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-2.0.3/lib/hanami/extensions/action.rb:92:in `finish'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-controller-2.0.2/lib/hanami/action/session.rb:43:in `finish'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-controller-2.0.2/lib/hanami/action/cookies.rb:23:in `finish'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-controller-2.0.2/lib/hanami/action.rb:332:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-2.0.3/lib/hanami/slice/routing/resolver.rb:78:in `block in resolve_slice_action'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-router-2.0.2/lib/hanami/router.rb:108:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/rack-2.2.7/lib/rack/method_override.rb:24:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/rack-2.2.7/lib/rack/session/abstract/id.rb:266:in `context'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/rack-2.2.7/lib/rack/session/abstract/id.rb:260:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/dry-monitor-1.0.1/lib/dry/monitor/rack/middleware.rb:36:in `block in call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/dry-monitor-1.0.1/lib/dry/monitor/clock.rb:15:in `measure'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/dry-monitor-1.0.1/lib/dry/monitor/rack/middleware.rb:36:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-router-2.0.2/lib/hanami/middleware/app.rb:40:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/hanami-2.0.3/lib/hanami/slice.rb:758:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/rack-2.2.7/lib/rack/static.rb:161:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/configuration.rb:270:in `call'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/request.rb:98:in `block in handle_request'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/request.rb:97:in `handle_request'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/server.rb:431:in `process_client'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/server.rb:233:in `block in run'
/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/gems/puma-6.2.2/lib/puma/thread_pool.rb:147:in `block in spawn_thread'

So looking at the complete trace now I see that it is duplicate view call execution which is invoking twice that block inside select method.

/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view.rb:568:in `call'

/home/jignesh/.rvm/gems/ruby-3.1.2@my-app/bundler/gems/view-35a90c2517e0/lib/hanami/view.rb:568:in `call'

Can anybody please help me understand such behavior that how just replacing a - with = in the haml file is causing duplicate invocation of view's call method?

And another question which is puzzling me is when using = with label and text_field methods why the duplicate label and input type=text tags were not rendered and the duplication was observed only for select's option tags.

Thanks.

@cllns cllns changed the title form_form - Duplicate option tags generated for select tag form_for - Duplicate option tags generated for select tag Oct 19, 2024
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

No branches or pull requests

1 participant