ruby on rails - Can't puts parameter from yield -


why can't puts parameter yield?

error:

undefined local variable or method `options' #<#<class:0x007fd1bd8735e8>:0x007fd1ba3e4fe8> 

/app/helpers/bootstrap_form_helper.rb

...   def inline     options = "row_disable"     content_tag(:div, class: "row test") { yield(options) }   end ... 

/app/views/signup/new.html.erb

...     <%= inline %>   <%= options %>   <%= person_f.text_field(:last_name, control_col: 7) %> <% end %> ... 

you cannot access local variable, options, defined in inline method. have access argument passed block inline method, , need have block in new.html.erb accept options argument:

  ...       <%= inline |options| %>     <%= options %>     <%= person_f.text_field(:last_name, control_col: 7) %>   <% end %>   ... 

just clarify little further, don't need call options in new.html.erb. following work:

  ...       <%= inline |foo| %>     <%= foo %>     <%= person_f.text_field(:last_name, control_col: 7) %>   <% end %>   ... 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -