我有一个列出找到的项目的搜索结果页面。在那个列表上,我有一个按钮,我想用它来显示结果的缩略图。
我有显示搜索到的图像的控制器方法:
def search
@search_criteria = params[:search]
@novels = Novel.where("lower(name) like ?", "%#{@search_criteria.downcase}%")
@novels.sort! { |a,b| a.name.downcase <=> b.name.downcase }
@searched_illustrations = Illustration.where("lower(name) like ?", "%#{@search_criteria.downcase}%")
@tagged_illustrations = Illustration.tagged_with([@search_criteria], :any => true, :wild => true)
@illustrations = @searched_illustrations + @tagged_illustrations
@illustrations.uniq!
@illustrations.sort! { |a,b| a.name.downcase <=> b.name.downcase }
respond_to do |format|
format.html #search_results.html.erb
end
end
这是我附加到显示搜索结果的视图上的按钮的代码:
<%= link_to "Show", illustration, :class => "btn btn-custom-primary btn-mini", :style => "float:right;" %>
这是我必须显示缩略图的控制器方法:
def show_illustrations
@illustrations = params[:illustrations]
@illustrations = Kaminari.paginate_array(@illustrations).page(params[:page]).per(20)
respond_to do |format|
format.html #search_results.html.erb
end
end
我收到了这个错误,这让我相信我得到了一组插图 ID 作为参数 [插图]:
undefined method `aws_image_thumbnail_url' for "2":String