【发布时间】:2014-03-17 17:40:26
【问题描述】:
所以,我不知道为什么,但是当我在文本框中输入一些文本然后刷新页面时,文本没有保存。我使用了正确的数据库字段(描述),所以我不确定出了什么问题。
_photo.html.erb
<%= best_in_place photo, :description, type: :textarea, nil: 'Enter a Caption' %>
照片架构
create_table "photos", force: true do |t|
t.string "file"
t.integer "attachable_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "attachable_type"
t.string "title"
t.text "description"
t.boolean "profile_photo", default: false
end
add_index "photos", ["attachable_id"], name: "index_photos_on_attachable_id", using: :btree
add_index "photos", ["attachable_type"], name: "index_photos_on_attachable_type", using: :btree
为什么不保存?
干杯!
更新:
show.js
$('.modal-title').html('<%= @photo.title %>');
$('.modal-body').html('<%= j(render "modal_photo", photo: @photo) %>');
$('#myModal').modal();
photos_controller(截图):
class PhotosController < ApplicationController
before_filter :authenticate_user!
def show
@photo = current_user.photos.find(params[:id])
end
【问题讨论】:
-
请添加控制器的内容和调用
_photo.html.erb部分的视图。 -
当然 - 我已经用节目和照片控制器相关代码更新了帖子。谢谢!
-
请添加您的控制器的
update操作。 -
您使用的是 Rails3 还是 Rails4?
-
Rails 4。让我删除它,对不起!
标签: ruby-on-rails ruby-on-rails-4 best-in-place