I have this form in /new.html.erb:
<%= form_for @vendor, multipart: true do |f| %>
<%= f.text_field :name, "Store Name" %>
<%= f.text_field :address, "Store Address" %>
<%= f.file_field :image %>
<%= f.submit "Save", class: "btn btn-success" %>
<% end %>
and these Vendor methods:
def new
@vendors = Vendor.all
@vendor = Vendor.new
end
def vendor_params
params.require(:vendor).permit(:id, :name, :latitude, :longitude, :address, :image)
end
When I try to render the page, I get this error:
undefined method `merge' for "Store Name":String
Extracted source (around line #8):
5: <h4>New Vendor Form</h4>
6:
7: <%= form_for @vendor, :html => {:multipart => true} do |f| %>
8: <%= f.text_field :name, "Store Name" %>
9: <%= f.text_field :address, "Store Address" %>
10: <%= f.file_field :image %>
11: <%= f.submit "Save", class: "btn btn-success" %>
I'm not sure why merge
is being called here. Is it in a hidden field possibly? Most of the answers I found pertaining to this error had to do with hidden fields. I'm using Geocoder to geocode lat and long after validation like so (not sure if this is relevant):
class Vendor < ActiveRecord::Base
geocoded_by :address
after_validation :geocode,
:if => lambda{ |obj| obj.address_changed? }
end
Any help here is much appreciated! Thanks in advance.