2.0.0p247 :022 > @post.title
=> "Breakfast Burrito"
2.0.0p247 :023 > solr = Refinery::Books::Book.search { fulltext @post.title.split(' ').join(' OR ') }
NoMethodError: undefined method `title' for nil:NilClass
from (irb):23:in `block in irb_binding'
from /usr/local/rvm/gems/[email protected]_development/gems/sunspot-2.1.0/lib/sunspot/util.rb:208:in `instance_eval'
내가 데리러 가지 않는 것이 있습니다. 참고 fulltext
은 해시가 아니며 search
은 해시가 아니라 블록을 사용합니다. .search
에 전달 블록 (instance_exec
, class_eval
, class_exec
) 방법 등 BasicObject#instance_eval
의 도움으로 다른 콘텍스트에서 평가 될 수있다누군가이 블록의 Ruby 코드에 대해 설명해 주시겠습니까? 변수가 블록 내부에서 null 인 이유는 무엇입니까?
2.0.0p247 :026 > solr = Refinery::Books::Book.search { fulltext 'burrito' }
SOLR Request (13.9ms) ...