我正在使用现有的外部数据库,其主键集具有浮动/双精度。除编辑外,所有操作都可以正常工作。
它给出的错误就是这个。 有没有办法解决这个问题或将其改为int是唯一的方法?
没有路线匹配[GET]" / subsystem_tbls /' 1.123' / edit"
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
答案 0 :(得分:0)
任何包含小数点作为主键的数据类型都不适用于rails。