我有一个带有 jQuery 内容轮播的城市页面。轮播的内容由每个循环归档。
CityController
@events = @city.events.find_all_by_hot(true)
@activities = @city.activities.find_all_by_hot(true)
@sights = @city.sights.find_all_by_hot(true)
@hot = @events + @activities + @sights
Class city
has_many: events
end
class events
belongs_to :city
has_many :attachments, :as => :attachable
accepts_nested_attributes_for :attachments
end
活动和景点模型相同
City view content slider:
@hot.each do |a|
a.attachments.each do |a|
= image_tag(a.file.url, :height =>"325px", :width =>"650px" ), url_path
我想在我的每个循环中生成链接(url_path)......我怎样才能实现这一点?它不能放置路由的 url_path,因为它们是动态的,基于加载的附件(图像)。