<div class="field"><%= form.label "当前街道名称" %><%= form.text_field :current_name, id: :street_current_name, placeholder: "Name at the end of period (Latest Confirmed Date)", :size=>"95%" %>
From the show.html.erb page I want to create a copy of the record on that page and be sent to the new.html.erb page. Rails dup method does that (and doesn't have and id or creation date), but I can't figure out how to get there.
The error I'm currently getting is this: Couldn't find Street with 'id'= pointing at the @street = Street.find(params[:id]).dup line in the streets_controller.rb. (This page has been updated with fixes to some of the problems I had. Thank you commenters.)
Part of my show.edit.erb page:
<p>
<strong>Previous Street Name:</strong>
<%= @street.previous_name %>
</p>
<p>
<strong>‘Current/Next’ Street Name:</strong>
<%= @street.current_name %>
</p>
<p>
<strong>Earliest Date for ‘Previous’ Name:</strong>
<%= @street.date_earliest %>
</p>
<p>
<strong>Latest Date for ‘Previous’ Name: </strong>
<%= @street.date_latest %>
</p>
<p>
<strong>Entry covers from cross street to cross street or similar:</strong>
<%= @street.cross_streets %>
</p>
<p>
<strong>Approximate Number of Blocks:</strong>
<%= @street.number_of_blocks %>
</p>
<p>
<strong>Length of segment:</strong>
<%= @street.extent_length.round(2) %> miles
</p>
<div class="container-fluid">
<p>This is for a street name from Previous Name/Earliest Date to Current Name/Latest Date</p>
<div class="row"> <!-- Setting up to have two columns -->
<div class="col-4"> <!--Left hand column. -->
<%= form_with(model: street, local: true) do |form| %>
<% if street.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(street.errors.count, "error") %> prohibited this street from being saved:</h2>
<ul>
<% street.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="form-inputs">
<div class="field">
<%= form.label "City" %>
<%= form.text_field :city, id: :street_city %>
</div>
<div class="field">
<%= form.label "Previous Name" %>
<%= form.text_field :previous_name, id: :street_previous_name %>
</div>
<div class="field">
<%= form.label "Current Street Name" %>
<%= form.text_field :current_name, id: :street_current_name, placeholder: "Name at end of period (Latest confirmed date)", :size=>"95%" %>
</div>
<div class="row">
<div class="col-lg-12 text-center font-bold">For Previous Street Name</div>
<div class="field col-lg-6">
<%= form.label "Earliest Confirmed Date" %>
<%= form.text_field :date_earliest, id: :street_date_earliest %>
</div>
<div class="field col">
<%= form.label "Latest Confirmed Date" %>
<%= form.text_field :date_latest, id: :street_date_latest %>
</div>
</div>
<div class="field">
<%= form.label "Entry covers from cross street to cross street or similar" %>
<%= form.text_area :cross_streets, id: :street_cross_streets, :maxlength=>"100%" %>
</div>
<div class="row">
<div class="col-lg-12 text-center font-bold">Extent of This Item</div>
<div class="field col-lg-6">
<%= form.label "Approximate Number of Blocks" %>
<%= form.text_field :number_of_blocks, id: :street_number_of_blocks %>
</div>
<div class="field col">
<%= form.label "Length of segment, miles" %>
<%= form.text_field :extent_length, id: :street_extent_length %>
</div>
</div>
<div class="field">
<%= form.label "Reference 1" %>
<%= form.text_area :ref1, id: :street_ref1, :maxlength=>"95%" %>
</div>
<div class="field">
<%= form.label "Reference 2" %>
<%= form.text_area :ref2, id: :street_ref2 %>
</div>
<div class="field">
<%= form.label "Reference 3" %>
<%= form.text_area :ref3, id: :street_ref3 %>
</div>
<div class="field">
<%= form.label :notes %>
<%= form.text_area :notes, id: :street_notes %>
</div>
<div class="field">
<%= form.label "Extent as JSON [lng lat]" %>
<%= form.text_field :extent_json, id: :street_extent_json, placeholder: "Will be automagically filled in when line is drawn!" %>
</div>
<% if @street.extent_array? %>
<div class="field">
<%= form.label "Extend as string (array lat lng)This column is replaced by the one above and will be removed." %>
<%= form.text_area :extent_array, id: :street_extent_array, placeholder: "Not currently being used except for pre-existing entries." %>
</div>
<% end %>
<div class="actions">
<%= form.submit "Create/Update Historical Street", class: "btn btn-primary" %>
</div>
</div> <!-- end form-inputs -->
<% end %> <!-- End of form -->
</div> <!-- end col-4, the left hand column -->
<!-- The next two columns -->
<%= render 'map_and_control_and_draw' %> <!-- middle column with map -->
<%= render 'overlaymap_selector' %> <!-- the third column for selector basemap -->
</div> <!-- end row -->
</div> <!-- end container-fluid -->
Seems like this would be a common request, but searching here and elsewhere and looking in my several Rails books; I only find things about Rails 2 or 3, and they don't go quite for enough for me to understand how to make that work in Rails 5. To reiterate the current error is: Couldn't find Street with 'id'= and the following from better_errors: