我有...
路线.rb:
resources :standards do
collection do
get :none
end
end
我得到以下内容rake routes
:
none_standards GET /standards/none(.:format) standards#none
我有以下内容standards_controller.rb
:
def none
end
那么为什么在 /standards/none 中会出现“找不到没有 ID 的标准”错误?
随着better_errors
,它说:
(gem) activerecord-3.2.11/lib/active_record/relation/finder_methods.rb
305
306 ids = ids.flatten.compact.uniq
307
308 case ids.size
309 when 0
310 raise RecordNotFound, "Couldn't find #{@klass.name} without an ID"
311 when 1
312 result = find_one(ids.first)
313 expects_array ? [ result ] : result
314 else
315 find_some(ids)
...
Instance Variables
@table
#<Arel::Table:0x007fc321207650 @name="standards", @engine=Standard(id: integer, name: string, description: string, created_at: datetime, updated_at: datetime), @columns=nil, @aliases=[], @table_alias=nil, @primary_key=nil>
@klass
Standard(id: integer, name: string, description: string, created_at: datetime, updated_at: datetime)
这是一个收集路线而不是成员路线,所以这看起来很奇怪。