I am using an existing external database which has primary key set has floating/double. All actions work fine except for edit.
The error it gives is this. Is there a way around this or changing it to int is the only way?
No route matches [GET] "/subsystem_tbls/'1.123'/edit"
Routes.rb
Rails.application.routes.draw do
root "subsystem_tbls#index"
resources :subsystem_tbls
resources :ui_types_tbls
resources :cmd_types_tbls
end
Controller
class SubsystemTblsController < ApplicationController
def index
@subs = SUBSYSTEM_TBL.all
end
def new
@subs = SUBSYSTEM_TBL.new
end
def show
@subs = SUBSYSTEM_TBL.find_by(params[:SUBSYSTEM_ID])
end
def edit
@subs = SUBSYSTEM_TBL.find_by(params[:SUBSYSTEM_ID])
end
def create
@subs = SUBSYSTEM_TBL.new(sub_params)
if @subs.save
redirect_to @subs
else
render 'new'
end
end
def update
@subs = SUBSYSTEM_TBL.find_by(params[:SUBSYSTEM_ID])
if @subs.update_attributes(sub_params)
redirect_to root_url
else
render 'edit'
end
end
def destroy
SUBSYSTEM_TBL.find_by(params[:SUBSYSTEM_ID]).destroy
redirect_to root_url
end
private
def sub_params
params.require(:subsystem_tbl).permit(:SUBSYSTEM_ID, :SUBSYSTEM_NAME)
end
end
Rake ROutes
root_path GET /
subsystem_tbls#index
subsystem_tbls_path GET /subsystem_tbls(.:format)
subsystem_tbls#index
POST /subsystem_tbls(.:format)
subsystem_tbls#create
new_subsystem_tbl_path GET /subsystem_tbls/new(.:format)
subsystem_tbls#new
edit_subsystem_tbl_path GET /subsystem_tbls/:id/edit(.:format)
subsystem_tbls#edit
subsystem_tbl_path GET /subsystem_tbls/:id(.:format)
subsystem_tbls#show
PATCH /subsystem_tbls/:id(.:format)
subsystem_tbls#update
PUT /subsystem_tbls/:id(.:format)
subsystem_tbls#update
DELETE /subsystem_tbls/:id(.:format)
subsystem_tbls#destroy