2012-12-15 1 views
1

나는 두 가지 모델이있다.중첩 검색 태양 흑점 solr을 어떻게 활성화 할 수 있습니까? <code>User</code> 및 User.rb에서 <code>User_profile</code></p> <p>, 사용자 <code>has_one :user_profile</code> :

In User_profile.rb, User_profile belongs_to :user.

그러면 users_controller와 해당 index.html.erb가 있습니다. 그래서 이것을 내 사용자 모델에 추가하여 중첩 된 열로 검색 할 수있게했지만 다시 색인하려고하면 오류가 표시됩니다. 이 문제를 어떻게 해결할 수 있습니까? #

에 대한

정의되지 않은 메서드`user_profiles '

모델/user.rb

당신은 당신의 user.rb 파일에 사용자 has_one :user_profile을 준
.... 
    searchable do 
    text :user_profile_nickname do 
     user_profiles.map { |user_profile| user_profile.nickname } 
    end 
    end 
.... 

답변

4

. 따라서 객체 컬렉션이 될 수는 없으며 객체 객체입니다. 따라서 사용자 모델에 user_profiles.map { |user_profile| user_profile.nickname }으로 전화 할 수 없습니다.

당신은 다음과 같은 쓰기를 호출 할 경우

searchable do 
    text :user_profile_nickname do 
    user_profile.nickname 
    end 
end 

은 위의 확실히 작동합니다. 일하지 않으면 알려주세요.

+0

감사합니다. 이것은 완벽하게 작동합니다! – HUSTEN

+0

안녕하세요. 계속해라. – VenkatK