因此,我正在使用最好的地方创业板,让用户编辑他们的照片标题到位。但是,输入的文本没有保存或存储在数据库中。
下面是与此领域相关的模式的快照:
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这是视图代码:
<p class="summary-info"><%= text_field photo, :description, placeholder: 'Add a description...' %></p>我做错了什么?
更新:
<p class="summary-info"><%= best_in_place photo, :description, type: :textarea, nil: 'Enter a Caption' %></p>发布于 2014-03-14 23:14:36
您没有在视图中使用best_in_place助手方法。查看自述文件或铁路#302。
你必须这样做:
<%= best_in_place @photo, :description, type: :input %>根据你的需要调整它。
text_field是Rails提供的辅助方法。
https://stackoverflow.com/questions/22417383
复制相似问题