我们可以像在java中那样公开Ruby中的接口,并强制执行Ruby模块或类来实现接口定义的方法.
一种方法是使用继承和method_missing来实现相同的目标,但还有其他更合适的方法吗?
环境:Rails 3.0.1 Ruby 1.8.7 MySQL 5.5.16社区服务器...... Jdk 1.6
gem 'sunspot_rails'
gem 'sunspot_solr'
Run Code Online (Sandbox Code Playgroud)
模型:
class Item < ActiveRecord::Base
searchable do
text :title,:description
end
end
Run Code Online (Sandbox Code Playgroud)
控制器:
def search
p @items = Item.search { fulltext params[:search] }
@items.results.each do |item|
p item
end
end
Run Code Online (Sandbox Code Playgroud)
我启动solr服务器,它启动正常,我在http:// localhost:8982/solr/admin /打开solr管理员
查询.... q = .但没有结果.
我运行rake sunspot:reindex ....新的索引文件在RAILS_ROOT\solr\data\development\index下创建.
我再次查询Solr管理员与相同的查询..still没有结果...试图找出什么是错的.