主键为浮动时无法执行编辑?

Cant perform edit when primary key is float?

我正在使用现有的外部数据库,该数据库的主键集有 floating/double。除编辑外,所有操作都正常。

它给出的错误是这样的。 有没有办法解决这个问题或将其更改为 int 是唯一的方法?

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

控制器

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

抽取路线

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

任何包含小数点作为主键的数据类型都不适合 rails。