有誰知道我如何從elasticsearcg(使用輪胎)索引的圖像獲取image.url?如何從索引的ElasticSearch模型獲取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) %>
我收到一個未定義的方法`網址」爲無:NilClass
任何人可以幫助我?
謝謝Ÿ提前