2014-11-10 2 views
1

중첩 된 리소스를 만들었지 만 link_to은 브라우저에 undefined method 'model_name' for Parking::ActiveRecord_Relation:Class을 표시합니다. 분명히 잘못 했어. 어떻게 해결할 수 있습니까?레일 링 중첩 리소스

index.rb

<%= link_to 'Create new parking', new_parking_path %></br> 
<%= link_to 'Rent place', [@parking, @place_rent]%> 

routes.rb는

resources :parkings do 
    resources :place_rents, :only => [:new, :create] 
    end 

답변

0

어느 @parking 또는 @place_rent는 관계 (컬렉션)이 아니라 당신이 경로를 구축 할 필요가 특정 모델이다. 이러한 변수 뒤에 무엇이 있는지에 따라 #first 또는 전체 쿼리가 필요할 수 있습니다.

관련 문제