我有以下上传者:
class HeroUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
include CarrierWave::RMagick
#include CarrierWave::MiniMagick
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
include Sprockets::Helpers::RailsHelper
include Sprockets::Helpers::IsolatedHelper
storage :fog
这是模型:
class Homepage < ActiveRecord::Base
attr_accessible :banner, :banner_text1, :banner_text2, :banner_text3, :button, :hero
mount_uploader :hero, HeroUploader
mount_uploader :banner, BannerUploader
mount_uploader :button, ButtonUploader
end
当我尝试在视图上调用Hero Image时,我得到: 私有方法`format'为amazons3.hat_beach.jpg调用:HeroUploader
横幅和按钮相同。我在同一个rails app中有另一个上传器。
有关如何解决此问题的任何想法?
谢谢!
萨姆
编辑以添加视图:
<body>
<div class="row-fluid" style="padding-top: 100px; padding-bottom: 30px;">
<div id="myCarousel" class="carousel slide" data-interval="30" >
<!-- Carousel items -->
<div class="carousel-inner">
<div class="item">
<div class="row-fluid">
<div class="span12">
<div class="row-fluid">
<div class="span6 offset1" >
<a align="center" href="http://pinterest.com/newoutfitpr/" target="_blank"> <%= image_tag @homepages.first.hero, class: "hero-image-size" %> </a>
</div>
<div class="span4">
<h3 align="center"><%= image_tag @homepages.first.banner %></h3>
<p class="product-description"><%= @homepages.first.banner_text1 %> </p>
<p class="product-description"><%= @homepages.first.banner_text2 %></p>
<p class="product-description"><%= @homepages.first.banner_text3 %></p>
<p align="center">
<%= link_to guest_collage_path, :method => :post do %>
<%= image_tag(@homepages.first.button, :alt => "Get Started") %>
<% end %></p>
</div>
</div>
</div>
</div>
</div>
答案 0 :(得分:1)
试试这个
而不是
<%= image_tag @homepages.first.banner %>
使用此
<%= image_tag @homepages.first.banner_url %>
请观看此视频直播视频