2013-02-15 3 views
0

내가 가지고 ...Rails가 # collection # 경로의 ID를 찾는 이유는 무엇입니까?

routes.rb :

none_standards GET /standards/none(.:format)     standards#none 

나는 내 standards_controller.rb에 다음과 같은 한 :

def none 
end 
나는 rake routes와 다음 수

resources :standards do 
    collection do 
     get :none 
    end 
    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) 

그것은 수집 경로 회원이 아니 경로, 그래서 이것은 매우 이상한 것 같다. 그 다음 설치와 함께 작동 나를 위해

+0

'레이크 라우트'출력이이 경로와 관련하여 어떻게 보이나요? –

+0

내 게시물에 세부 정보 추가 –

답변

1

이다 (당신의 경로가 말하는 것을 확인). 나는 filter_resource_access (정규 루트를 가정 함)을 standards_controller.rb에있는 filter_access_to :all (모든 경로를 포함)으로 변경해야했습니다.

0

이상한!는

#app/controllers/standards_controller.rb 
class StandardsController < ApplicationController 
    def none 

    end 
end 

#config/routes.rb 
resources :standards do 
    collection do 
    get :none 
    end 
end 

내 노선들은 문제가 declarative_authorization로했다

none_standards GET /standards/none(.:format)  standards#none 
    standards GET /standards(.:format)   standards#index 
       POST /standards(.:format)   standards#create 
    new_standard GET /standards/new(.:format)  standards#new 
edit_standard GET /standards/:id/edit(.:format) standards#edit 
     standard GET /standards/:id(.:format)  standards#show 
       PUT /standards/:id(.:format)  standards#update 
       DELETE /standards/:id(.:format)  standards#destroy 
      root  /
관련 문제