Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails CarrierWave在文件列处保存NULL_Ruby On Rails_Ruby_Carrierwave - Fatal编程技术网

Ruby on rails CarrierWave在文件列处保存NULL

Ruby on rails CarrierWave在文件列处保存NULL,ruby-on-rails,ruby,carrierwave,Ruby On Rails,Ruby,Carrierwave,im使用名为Photo的模型,该模型引用了Uploader类 class Photo < ActiveRecord::Base attr_accessible :title, :album_id belongs_to :album mount_uploader :photo_image, PhotosUploader end class Album < ActiveRecord::Base attr_accessible :title, :autor,

im使用名为Photo的模型,该模型引用了Uploader类

class Photo < ActiveRecord::Base
  attr_accessible :title, :album_id
  belongs_to :album
  mount_uploader :photo_image, PhotosUploader
end



class Album < ActiveRecord::Base    
  attr_accessible :title, :autor, :photos_attributes
  has_many :photos, :dependent => :destroy
  accepts_nested_attributes_for :photos  
end
class-Photo:销毁
接受\u嵌套的\u属性\u用于:照片
结束
但是。。当我尝试用图像保存新相册(或编辑,无论什么…)时,它不会保存文件(collumn photo_图像保存为空,文件也不会存储)

…视图/相册/_form.html.erb

<%= f.fields_for :photos do |f| %>
    <div class="field">
    <%= f.label :photo_image %><br />
        <%= f.file_field :photo_image %>
    </div>
<% end %>



有什么建议吗?

只要试着在photo model中添加
:photo\u image
attr\u accessible
,它可能会对您有所帮助


另外,请检查您的
日志/development.log

您使用的Rails版本是什么?Rails 3.1.3和ruby 1.9.3-rc1duh..运行良好!我确实认为需要添加照片图像,因为只有在相册模型上才可能。tks!如果没有它,Rails将忽略提交后的数据。祝您好运!:)