rails从paperclip迁移到carrierwave_direct

时间:2013-12-17 15:52:09

标签: file-upload amazon-s3 paperclip carrierwave

我已从Paperclip迁移到Carrierwave,并使用Carrierwave_direct将图像直接上传到S3。

class User < ActiveRecord::Base
    mount_uploader :profile_picture, ProfilePictureUploader, :mount_on => :profile_picture_file_name

因此,在我的架构中,我的用户表中没有列profile_picture而是profile_picture_file_name

当我尝试创建@uploader实例变量

时,这会产生问题
class ProfilePictureController < ApplicationController
  def show
    @user=current_user
    @uploader = @user.profile_picture_file_name
    @uploader.success_action_redirect = crop_url
  end

当用户尝试上传个人资料图片时,会抛出错误, undefined method `success_action_redirect=' for nil:NilClass

1 个答案:

答案 0 :(得分:0)

我想这可以解决它:

@uploader = @user.profile_picture