Carrierwave使用S3上传未在轨道4上显示的图像

时间:2014-04-22 04:00:22

标签: ruby-on-rails amazon-s3 carrierwave

此代码中未显示使用Carrierwave和Amazon S3图像

<div id="gallery">
  <div id="innerPictureFrame">
    <% @gallery.gamepics.each do |gamepic| %>
      <div class="gamepic">
        <%= image_tag(gallery.gamepic.thumb.to_s, :size => '200x200') %>
        <div class="name"><%= gamepic.name %></div>
        <div class="actions">
          <%= link_to "edit", edit_gamepic_path(gamepic) %>
          <%= link_to "remove", gamepic, :confirm => 'Are you sure?', :method => :delete %>
        </div>
     </div>
    <% end %>
<div class="clear"></div>

和这个控制器

def create
  @gallery = Gallery.new(gallery_params)
    if @gallery.save
      flash[:notice] = "Successfully created gallery."
      redirect_to @gallery
    else
      render :action => 'new'
    end
end

使用railscast 253中的样本

编辑 - 我检查了heroku上的Postgres数据库,看起来很好,所以显示错误或模型错误

模特 -

Gamepic

class Gamepic < ActiveRecord::Base
  belongs_to :gallery
  mount_uploader :gamepic, GamepicUploader

  private 
    def gamepic_params
      params.require(:gamepic).permit(:gameid, :gamename, :gamepic)
    end
end

class Gallery < ActiveRecord::Base
  has_many :gamepics

  private 
    def gallery_params
      params.require(:gallery).permit(:name, :gallery, :gamepic)
  end

end

0 个答案:

没有答案