Ruby on rails 已添加回形针-现在型号不接受更新

Ruby on rails 已添加回形针-现在型号不接受更新,ruby-on-rails,ruby-on-rails-3,amazon-web-services,paperclip,Ruby On Rails,Ruby On Rails 3,Amazon Web Services,Paperclip,目前,我有一个“位置”模型,该模型在表单中添加了一个图像上载字段。当我去,让我们说“更新一个现有的位置,甚至添加一个新的,它将正确上传图像和显示它,但不会保存任何输入字段 如果我删除了表单上的upload photo(上传照片)字段,并且不需要它,那么所有内容都会正确更新和保存。因此,当出现图像时,它会保存图像,但不会保存其余字段 有没有关于为什么会发生这种情况的建议 Locations.rb class Location < ActiveRecord::Base belongs_t

目前,我有一个“位置”模型,该模型在表单中添加了一个图像上载字段。当我去,让我们说“更新一个现有的位置,甚至添加一个新的,它将正确上传图像和显示它,但不会保存任何输入字段

如果我删除了表单上的upload photo(上传照片)字段,并且不需要它,那么所有内容都会正确更新和保存。因此,当出现图像时,它会保存图像,但不会保存其余字段

有没有关于为什么会发生这种情况的建议

Locations.rb

class Location < ActiveRecord::Base

  belongs_to :region
  has_many :spots


  validates_attachment_size :photo, :less_than => 5.megabytes
  validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/png']

   has_attached_file :photo,
                :styles => { :thumb => "150x150#", :medium => "200x200#"},
                :path => ":attachment/:id/:style.:extension",
                :s3_domain_url => "adsimgstore.s3.amazonaws.com",
                :storage => :s3,
                :s3_credentials => Rails.root.join("config/s3.yml"),
                :bucket => 'adsimgstore',
                :s3_permissions => :public_read,
                :convert_options => { :all => "-auto-orient" }


   attr_accessible :locations, :photo, :photo_file_name, :photo_content_type, :photo_file_size,     :photo_updated_at
end
类位置5.MB
验证附件内容类型:照片,内容类型=>['image/jpeg','image/png']
已附上文件:照片,
:style=>{:thumb=>“150x150”,:medium=>“200x200”,
:path=>“:attachment/:id/:style.:extension”,
:s3\u domain\u url=>“adsimgstore.s3.amazonaws.com”,
:storage=>:s3,
:s3_credentials=>Rails.root.join(“config/s3.yml”),
:bucket=>“adsimgstore”,
:s3\u权限=>:公共\u读取,
:convert_options=>{:all=>“-auto-orient”}
属性可访问:位置,:照片,:照片文件名,:照片内容类型,:照片文件大小,:照片更新位置
结束
形式

{:multipart=>true}do | f |%>
禁止保存此位置:












您是否尝试对该行进行注释

   attr_accessible :locations, :photo, :photo_file_name, :photo_content_type, :photo_file_size,     :photo_updated_at

你能复制模型和表单吗?更新后-还要注意:photo字段是在以后通过回形针“添加”到模型中的。因此不确定当前表是否与:photo关联
<div class="field">
  <%= f.label :name %><br />
  <%= f.text_field :name %>
</div>

<div class="field">
  <%= f.label :network_id %><br />
  <%= f.text_field :network_id %>
</div>

<div class="field">
  <%= f.label :region_id %><br />
  <%= f.text_field :region_id %>
</div>

<div class="field">
  <%= f.label :spot_duration %><br />
  <%= f.text_field :spot_duration %>
</div>

<div class="field">
  <%= f.label :frequency %><br />
 <%= f.text_field :frequency %>
</div>

<div class="field">
  <%= f.label :screen_count %><br />
  <%= f.text_field :screen_count %>
</div>

<div class="field">
  <%= f.label :ad_size %><br />
  <%= f.text_field :ad_size %>
</div>

<div class="field">
  <%= f.label :ad_type %><br />
  <%= f.text_field :ad_type %>
</div>

<div class="field">
  <%= f.label :impressions %><br />
  <%= f.text_field :impressions %>
</div>

<div class="field">
  <%= f.label :rate_card %><br />
  <%= f.text_field :rate_card %>
</div>

<div class="field">
  <%= f.file_field :photo %>
</div>

<div class="field">
  <td><%= image_tag @location.photo.url(:thumb) %></td>
</div>

<div class="actions">
  <%= f.submit %>
</div>
<% end %>
   attr_accessible :locations, :photo, :photo_file_name, :photo_content_type, :photo_file_size,     :photo_updated_at