【发布时间】:2014-03-22 00:50:21
【问题描述】:
我正在使用best_in_place 来更新我使用paperclip 创建的照片的名称。数据库中的文件名正在更新,但实际存储的文件 (/public/system/photos/attachments/...) 并未更新以反映更改后的名称。
结果是应用寻找不存在的新文件名:
没有路线匹配 [GET] "/system/photos/attachments/000/000/011/original/new_file_name.jpg"
照片控制器:
def update
@photo = Photo.find(params[:id])
respond_to do |format|
if @photo.update_attributes(photo_params)
format.html { redirect_to(new_photo_path, :notice => 'Photo was successfully updated.') }
format.json { respond_with_bip(@photo) }
else
format.html { render :action => "edit" }
format.json { respond_with_bip(@photo) }
end
end
end
照片(新)视图:
<% @photos.each do |photo| %>
<%= best_in_place photo, :attachment_file_name, :type => :input %>
<% end %>
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 paperclip best-in-place