2013-11-29 5 views
1

최근 내 Rails 4 앱에 friendly_id 5를 설치했습니다.# <ActiveRecord :: Relation []>에 대해 정의되지 않은 메소드`friendly '

undefined method `friendly' for #<ActiveRecord::Relation []> 

이 발생 : 나는 공식 :: 마스터를 저장하려고하면

class Official::Master < Official 
    extend FriendlyId 
    friendly_id :name, use: [:slugged, :history] 

end 

은, 그러나, 나는이 오류가 발생합니다 : 나는 빠른 시작 가이드 및 설정이 같은 모델을 따랐습니다 create 컨트롤러 액션에서 :

def create 
    official = Official::Master.new(official_params) 
    official.save # error occurs on this line 
end 

불행하게도, 레일은 일반적으로 않는 스택 추적을 생산하지 않습니다. 나는이 오류를 해결하는 방법을 놓치고있다.

는 UPDATE :

는 역 추적 소음기를 제거하고있어이 :

는 오류가 slugged.rb 라인 (302)에 같은

activerecord (4.0.1) lib/active_record/relation/delegation.rb:121:in method_missing' activerecord (4.0.1) lib/active_record/relation/delegation.rb:68:in method_missing' friendly_id (5.0.1) lib/friendly_id/slugged.rb:302:in scope_for_slug_generator' friendly_id (5.0.1) lib/friendly_id/history.rb:104:in scope_for_slug_generator' friendly_id (5.0.1) lib/friendly_id/slugged.rb:313:in slug_generator' friendly_id (5.0.1) lib/friendly_id/slugged.rb:294:in set_slug'

가 보이는 :

그것은이다
scope = scope.friendly unless friendly_id_config.uses? :finders 

답변

2

는 friendlyid 보인다 5 레일 4에서 단일 테이블 상속을 올바르게 처리하지 못했습니다. 아래 코드를 상위 클래스에 추가하면 어떻게됩니까? 그 확실히 버그의 원인이다, Friendly_id 5 rc1 - single table inheritance issue

+0

감사합니다 : 여기

extend FriendlyId friendly_id :name, use: [:slugged, :history] 

그리고

더 많거나 적은 같은 문제를 해결하는 문제이다. 불행히도,이 솔루션은 내 유스 케이스에서는 실행 가능하지 않습니다. 공식의 고유 한 다른 모델에는 친숙한 ID가 없어야합니다. 아직도 무슨 일이 일어나고 있는지 잘 알고 있습니다. – nullnullnull

+0

사실, 귀하가 제공 한 링크가이를 처리하는 방법에 대한 제안을 가지고있는 것처럼 보입니다. 그 힌트를 가지고 일하는 모든 것을 얻었습니다. – nullnullnull

관련 문제