ruby-on-rails – rails carrierwave_direct无法呈现direct_upload_form_for表单

ruby-on-rails – rails carrierwave_direct无法呈现direct_upload_form_for表单,第1张

概述我尝试在我的rails 3.2应用程序中为某些图像上传设置了carrierwave_direct,但似乎无法使用direct_upload_form_for标记呈现表单. 我收到错误“未定义的方法`direct_fog_url’用于#< PostmarkerImage:0x007fdbe07b39f0>”加载包含表单的页面时. PostmarkerImage是我安装上传器的模型,如下所示: cla 我尝试在我的rails 3.2应用程序中为某些图像上传设置了carrIErwave_direct,但似乎无法使用direct_upload_form_for标记呈现表单.

我收到错误“未定义的方法`direct_fog_url’用于#< PostmarkerImage:0x007fdbe07b39f0>”加载包含表单的页面时.

PostmarkerImage是我安装上传器的模型,如下所示:

class PostmarkerImage < ActiveRecord::Base  attr_accessible :image,:image_cache  belongs_to :postmarker  valIDates :image,:presence => true  mount_uploader :image,PostmarkerImageUploaderend

image列是一个字符串,我还确保已运行迁移以创建列.上传者现在看起来像这样:

class PostmarkerImageUploader < CarrIErWave::Uploader::Base  include CarrIErWaveDirect::Uploader  # 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  # Choose what kind of storage to use for this uploader:  # storage :file  # storage :fog  include CarrIErWave::MimeTypes  process :set_content_type  # ProvIDe a default URL as a default if there hasn't been a file uploaded:  # def default_url  #   # For Rails 3.1+ asset pipeline compatibility:  #   # asset_path("fallback/" + [version_name,"default.png"].compact.join('_'))  #  #   "/images/fallback/" + [version_name,"default.png"].compact.join('_')  # end  # Process files as they are uploaded:  # process :scale => [200,300]  #  # def scale(wIDth,height)  #   # do something  # end  # Create different versions of your uploaded files:  # version :thumb do  #   process :scale => [50,50]  # end  # Add a white List of extensions which are allowed to be uploaded.  # For images you might use something like this:  def extension_white_List    %w(jpg jpeg gif png)  end  # OverrIDe the filename of the uploaded files:  # AvoID using model.ID or version_name here,see uploader/store.rb for details.  # def filename  #   "something.jpg" if original_filename  # endend

我还确保已经安装了carrIErwave_direct,fog,mini_magick和Imagemagick.我可以知道我还错过了什么吗?看起来上传器的安装似乎没有正确完成.

解决方法 管理想出来:)以防万一有人有这个问题:

我正在实现一个单独的模型来保存我的图像,而不是将列添加到现有的表中.因此,direct_upload_form_for需要列(例如Image.new.image)而不是我返回的Object(例如Image.new).我想我被form_for部分抛弃了,它通常需要一个Object!

总结

以上是内存溢出为你收集整理的ruby-on-rails – rails carrierwave_direct无法呈现direct_upload_form_for表单全部内容,希望文章能够帮你解决ruby-on-rails – rails carrierwave_direct无法呈现direct_upload_form_for表单所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1290122.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存