我的Ruby版本:红宝石1.8.7(2011-02-18 patchlevel 334)[i386-mingw32] 我的Rails版本:Rails 2.3 0.11Rails:没有路由匹配时,我重写模型中的默认id并使用命名路由
我得到的错误是:
No route matches "/hcfcdsensors/4513.0/show_graph_hcfcd" with {:method=>:post}
这里是我的模型
class Hcfcdsensor < ActiveRecord::Base
set_primary_key :device_id
has_one :hcfcdsensorvalue
has_many :hcfcdraindatas
end
class Hcfcdsensorvalue < ActiveRecord::Base
belongs_to :hcfcdsensor
end
class Hcfcdraindata < ActiveRecord::Base
set_table_name 'hcfcdraindata'
belongs_to :hcfcdsensor
end
我的航线有:
map.resources :hcfcdraindatas
map.resources :hcfcdsensors
map.show_graph_hcfcd 'hcfcdsensors/:device_id/show_graph_hcfcd', :controller => 'hcfcdsensors', :action => 'show_graph_hcfcd'
的link_to_remote声明:
<%= link_to_remote "show" , :url => show_graph_hcfcd_url(@hcfcdsensors[0]) ,:update => "graphDiv" %>
的 “DEVICE_ID” 字段的类型为double。这个路由系统工作正常,如果我删除主键覆盖并用“:id”替换路由中的“:device_id”
任何帮助,非常感谢。
感谢, Shaunak
谢谢tadman。这工作完美!的确。混淆了路由引擎。 – Shaunak 2011-04-27 04:54:08