【发布时间】:2023-03-26 19:22:02
【问题描述】:
我有一个在 Nitrous.io 上运行的应用程序,安装了 Ruby 2 和 Rails 4.0。
我安装了carrierwave 和Mini_magick gem,但我的图片似乎仍然没有上传。
我有以下设置:
profile_uploader.rb
class ProfileUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
模型 - list.rb
class List < ActiveRecord::Base
mount_uploader :profile, ProfileUploader
end
新建.html.haml
= form_for @list, :html => {:multipart => true} do |f|
.field
= f.label :name
= f.text_field :name
.field
= f.label :telephone
= f.text_field :telephone
.field
= f.label :Profile_image
= f.file_field :profile
= f.hidden_field :profile_cache
= f.submit
= link_to 'Back', lists_path
真的无法弄清楚为什么这不起作用,因为我相信一切都设置正确。人们可以提供的任何帮助都会很棒!
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 carrierwave minimagick