CKEditor的第二个实例没有保存到db | Ruby on Rails
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CKEditor的第二个实例没有保存到db | Ruby on Rails相关的知识,希望对你有一定的参考价值。
我有一个表单,用于创建/更新我的rails应用程序中称为“包”的产品。 CKEditor的第一个实例是保存到数据库并在show视图中工作,但第二个实例不是。
我已经尝试将db列名称重命名为其他名称,以防它是一个冲突的名称,但这似乎也没有改变任何东西。
包/ new.html.erb:
<div class="wellington center news-form">
<%= simple_form_for Pack.new do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= f.input :title, class: "form-control center" %> <!-- "Name of pack or soundtrack" -->
<%= f.input :description, :as => :ckeditor, input_html: {:ckeditor => {:toolbar => 'FULL'}}, class: "form-control left" %> <!-- "Description of pack" -->
<%= f.input :pack_contents, :as => :ckeditor, input_html: {:ckeditor => {:toolbar => 'FULL'}}, class: "form-control left" %> <!-- "Use a <ul> to list included items" -->
<%= f.input :pack_type, class: "form-control center" %> <!-- "Category of pack/product (Sound library, Vocal pack, soundtrack category, plugin preset pack.)" -->
<%= f.input :category_id, prompt: "Select Category", collection: [ "sample-pack", "vocal-pack", "preset-pack", "track-pixel", "track-indie", "track-orchestral"], input_html: { class: "form-control center" } %> <!-- What product is this? -->
<%= f.input :price, class: "form-control center" %> <!-- "Product price (Just the #)" -->
<%= f.input :audio_embed, class: "form-control center" %> <!-- "Soundcloud embed link inside the iframe src" -->
<%= f.input :art_link, prompt: "ENTER N/A IF STRACK", class: "form-control center" %> <!-- "Cover art for product (file name)" -->
<%= f.input :download_url, class: "form-control center" %> <!-- Download Source -->
<%= f.submit "Add product to grid", class: "btn btn-success btn-block" %>
<% end %>
<%= link_to "Cancel", packs_path, class: "btn btn-danger top-drop" %>
</div>
包/ show.html.erb:
<div class="description"><%= raw @pack.description %></div>
<div class="pack-contents"><%= raw @pack.pack_contents %></div>
在此先感谢,我感谢您的帮助!
更新:
packs_controller:
private
def pack_params
params.require(:pack).permit(:art_link, :title, :description, :price, :pack_type, :pack_class, :audio_embed, :category_id, :download_url)
end
答案
您需要在控制器中允许pack_contents
参数,以便将其保存在模型中。
以上是关于CKEditor的第二个实例没有保存到db | Ruby on Rails的主要内容,如果未能解决你的问题,请参考以下文章