有谁知道我如何从 elasticsearcg 索引的图像中获取 image.url(使用轮胎)?
class Photo < ActiveRecord::Base
include Tire::Model::Search
include Tire::Model::Callbacks
attr_accessible :caption, :user_id, :image, :venue_id
attr_accessible :id, :image_file_name, :created_at, :updated_at, :city, :state, :country, :image_url
has_attached_file :image, :styles => { :large => "9999x9999", :medium => "300x200>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
end
class SearchController < ApplicationController
def index
city_name = params[:city]
@photos = Photo.search city_name
respond_to do |format|
format.html # index.html.erb
end
end
结尾
当我这样做时,在我的 index.html.erb 中:
<% @photos.each do |photo| %>
<%= image_tag photo.image.url(:medium) %>
我收到 nil:NilClass 的未定义方法“url”
有谁能够帮我 ?
非常感谢你提前