최근 내 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:inscope_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:inslug_generator' friendly_id (5.0.1) lib/friendly_id/slugged.rb:294:in
set_slug'
가 보이는 :
그것은이다scope = scope.friendly unless friendly_id_config.uses? :finders
감사합니다 : 여기
그리고
더 많거나 적은 같은 문제를 해결하는 문제이다. 불행히도,이 솔루션은 내 유스 케이스에서는 실행 가능하지 않습니다. 공식의 고유 한 다른 모델에는 친숙한 ID가 없어야합니다. 아직도 무슨 일이 일어나고 있는지 잘 알고 있습니다. – nullnullnull사실, 귀하가 제공 한 링크가이를 처리하는 방법에 대한 제안을 가지고있는 것처럼 보입니다. 그 힌트를 가지고 일하는 모든 것을 얻었습니다. – nullnullnull