我有这样一部分“看起来像鬼”的代码(但它必须如此,因为 db 很大并且有很多表):
def search_group
@search_trees = SearchTree.all
@designation = Designation.find(:all, :conditions => { :DES_ID => @search_trees.map(&:STR_DES_ID)})
@text = DesText.find(:all, :conditions => { :TEX_ID => @designation.map(&:DES_TEX_ID)})
@search_result = @text.find_all{|item| item.TEX_TEXT.include?(params[:search_group_text])}
@designation_back = @designation.find_all{|item| item.DES_TEX_ID == @search_result.TEX_ID}
@search_trees_back = @search_trees.find_all{|item| item.STR_DES_ID == @designation_back.DES_ID}
respond_to do |format|
format.html
end
end
我试着比较
@designation_back = @designation.find_all{|item| item.DES_TEX_ID == @search_result.TEX_ID}
但我得到错误,一些不好的东西......未定义的方法'TEX_ID'。我认为,这是通过我以不好的方式比较哈希和哈希...我该怎么做?