0

I have the following uploader:

    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

This is the model:

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

When I try to call the Hero Image on a view, I get: private method `format' called for amazons3.hat_beach.jpg:HeroUploader

Same for the Banner and Button. I do have another uploader in the same rails app.

Any ideas on how to fix this?

Thanks!

Sam

Editing to add the view:

  <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>
4

1 回答 1

1

试试这个

代替

<%= image_tag @homepages.first.banner %>

用这个

<%= image_tag @homepages.first.banner_url %>

请观看此 railscasts 视频

http://railscasts.com/episodes/253-carrierwave-file-uploads

于 2013-07-24T17:42:59.893 回答