Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add default value to a number_field in rails?

I've created a form

<%= form_for [current_user,@product,@bid] do |f| %>   <p><%= f.number_field :bid_amount %></p>   <p><%= f.number_field :product_id %>   <p><%= f.submit 'Bid!' %></p> <% end %> 

In the :product_id field I want add @product.id by default, how to implement this?

like image 397
Rajdeep Singh Avatar asked Sep 04 '13 07:09

Rajdeep Singh


1 Answers

 <p><%= f.number_field :product_id, :value => @product.id %></p> 

more details on: NumberField

like image 192
Rajarshi Das Avatar answered Oct 08 '22 11:10

Rajarshi Das