I have a page for viewing each individual customer, which then has a form at the bottom of it to enter a new license, i want that form to automatically fill the hidden field with the id of the current pages customer. Here is the code for my hidden field:
<%= f.hidden_field :customer_id, :value => '1' %>
I’ve currently set the value to 1, which works, but i need it to automatically use the ID instead. this is what’s in my controller for this view:
def show
@customer = Customer.find(params[:id])
@license = License.find_by_customer_id(@customer.id)
@software = Software.all
@licenses = License.new
respond_to do |format|
format.html # show.html.erb
format.json { render json: @customer }
end
end
Try
<%= f.hidden_field :customer_id, :value => @customer.id %>