bundlen install 后我重新启动了服务器
我的环境
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.4.0]
如果我删除 book.rb 中的搜索功能,它会显示给我
undefined method `*' for Ransack::Search<class: Book, base: Grouping <combinator: and>>:Ransack::Search
如果我在 book.rb 中添加搜索功能
它向我展示了
undefined method `result' for #<Array:0x007f9fa40327d0>
索引.html
def index
@carts = Cart.all
@search = Book.search(params[:q])
puts @search*50
@books = @search.result
puts @search.methods
respond_to do |format|
format.html # index.html.erb
format.json { render json: @carts }
end
end
书本.rb
def self.search(isbn)
if isbn
find(:all, :conditions => ['isbn=?', "#{isbn}"])
else
find(:all)
end
end