ruby - How to add custom name input field in rails simple_form_for -


@tech_data = tagnode.first outputs below object controller .

p @tech_data #<tagnode _id: 5119dcf74054448e576f3392, parent_id: nil, parent_ids: [], name: "categories", path: "categories", _type: "tagnode"> 

i have form has fields name, _type, , category. object doesn't have field category.

here's form

  = simple_form_for @tech_data, as: :techtags, :url => view_techtags_technologies_path, :remote => true,:method => :get,:html => {:id => "upsert_techtags",:data => {:spinner => "#tech-ui"}} |f|   %label.pull-left type   = f.input :_type, :collection => tech_types, :label => false, :input_html => {:class =>"chzn-select", :data => {:placeholder => "select technology type"}, :multiple => false}   %label.pull-left name   = f.input :name, :type=>"text", :required => true, :label => false, :placeholder =>"type new technology", :input_html => {:style => "width:265px;margin-bottom:0;"}   %label.pull-left category   = f.input :category, :collection => [1,2,3,4], :label => false, :input_html => {:class =>"chzn-select", :disabled=>"true",:data => {:placeholder => "type or select category"}, :multiple => false}   = f.submit "create", :class => "btn btn-primary pull-right" 

my form has additional field object doesn't have. error when form loaded, don't have category field in object.

how can select category value in form without adding field model?

you need attr_accessor in ruby,what attr_accessor in ruby? please include following in model,which make values form controller. attr_accessor :category


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -