我正在尝试将参数传递给我的f.text_field但我一直收到错误。 "错误的参数数量(3为1..2)"
<%= f.text_field :location, params[:location], placeholder: "Enter Zipcode", class: "form-control" %>
答案 0 :(得分:2)
def edit
@city = City.find_by(id: params[:id])
end
<%= form_for(@city, :html => { :multipart => true, :class => "form-horizontal" }) do |f| %>
<%= f.text_field :location, class: "form-control", required: :required, placeholder: "Enter Zipcode" %>
<% end %>
答案 1 :(得分:1)
<%= f.text_field :location, placeholder: "Enter Zipcode", value: params[:location], class: "form-control" %>