我使用的是一个现有的外部数据库,它的主键集为floating/double。除编辑操作外,所有操作都可以正常工作。
它给出的错误是这样的。
有没有办法解决这个问题,或者将其更改为int是唯一的方法?
没有与[获取]“/subsystem\u tbls/'1.123'/编辑”匹配的路由
路线。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