When I visit:
URL/salvage/25605
ActiveRecord shows an error RecordNotFound
Couldn't find Salvage without an ID
Parameters:
{"id"=>"25605"}
Why is ActiveRecord searching for "id" when I included "typeID" in the params?
Controller
class SalvageController < ApplicationController
def show
@salvage = Salvage.find(params[:typeID])
end
Model
class Salvage < ApplicationRecord
validates :typeID, presence: true
validates :amount, presence: true
end
View
<%= @salvage.typeID %>, <%= @salvage.amount %>
Resources
resources :salvage
Rails Routes
Prefix Verb URI Pattern Controller#Action
salvage_new GET /salvage/new(.:format) salvage#new
root GET / application#hello
production_pages_copying GET /production_pages/copying(.:format) production_pages#copying
salvage_index GET /salvage(.:format) salvage#index
POST /salvage(.:format) salvage#create
new_salvage GET /salvage/new(.:format) salvage#new
edit_salvage GET /salvage/:id/edit(.:format) salvage#edit
salvage GET /salvage/:id(.:format) salvage#show
PATCH /salvage/:id(.:format) salvage#update
PUT /salvage/:id(.:format) salvage#update
DELETE /salvage/:id(.:format) salvage#destroy
I am following the ruby on rails 6th edition tutorial on learnenough.com a second time around using my own data