Passing id through the check_box value in Ruby on Rails using form_for -


i have 2 controller project_controller.rb , service_controller.rb . have field in project named service_id.

when create project, value of service_id kept null default. need update service_id field of project id of service.

for have created form using project object. shown below :

<%= form_for(@project) |f| %>   <div class="field">     <%= f.label :name %><br />     <%= f.text_field :name %>   </div>   <div class="field">     <% @services.each |service| %>       <%= f.label "#{service.name}" %>     # here want pass array of       <%= f.check_box :service_id %>       # service_id through value of check box     <% end %>   </div>   <div class="actions">     <%= f.submit %>   </div> <% end %> 

now in source coming this..

enter image description here

please .. thanks

if refer rails api see

check_box(method, options = {}, checked_value = "1", unchecked_value = "0") 

so, pass custom value check box, need

<%= f.check_box :service_id, {}, service.id, '' %> 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -