ruby - Rails Undefined Helper Method Call Within Same Helper -
so, have weird problem. have helper method in rails 3.2.9 keeps giving me method not found error when trying phone call method within same module. i've tested in rails console , works expected. here's code:
helper module:
module somehelper def options_for(field, options={}) somehelper.send(field).merge options end def seller_f_name_options() {placeholder: 'first name'} end def seller_l_name_options() {placeholder: 'last name'} end def seller_email_options() {placeholder: 'email'} end end
controller view
<%= f.text_field :seller_l_name, options_for(:seller_l_name_options, {placeholder: 'altfntext'}) %>
rails error:
nomethoderror in landing_pages#index showing /var/www/application/app/views/landing_pages/_form_lp2.html.erb line #24 raised: undefined method `seller_l_name_options' somehelper:module extracted source (around line #24): 21: </div> 22: <div style="float:right; width:50%;"> 23: <%= f.label "last name", :style=>"margin-left: 8px;" %><br> 24: <%= f.text_field :seller_l_name, options_for(:seller_l_name_options, {placeholder: 'none'}) %> 25: </div> 26: </div> 27: trace of template inclusion: app/views/landing_pages/template2.html.erb rails.root: /var/www/application application trace | framework trace | total trace app/helpers/some_helper.rb:2:in `options_for' app/views/landing_pages/_form_lp2.html.erb:24:in `block in _app_views_landing_pages__form_lp__html_erb__4594666433786154550_70236178320020' app/views/landing_pages/_form_lp2.html.erb:8:in `_app_views_landing_pages__form_lp__html_erb__4594666433786154550_70236178320020' app/views/landing_pages/template2.html.erb:69:in `_app_views_landing_pages_template__html_erb__187408593000100027_35017480' app/controllers/landing_pages_controller.rb:29:in `index' config/initializers/quiet_assets.rb:7:in `call_with_quiet_assets'
any help on issue appreciated!
there's no need phone call through module, mean somehelper.send(field)
. these methods instance methods, plenty utilize send(field)
.
this problem more elaborated here.
ruby-on-rails ruby ruby-on-rails-3 metaprogramming
No comments:
Post a Comment