CKEditor的第二个实例未保存到数据库Ruby on Rails

时间:2018-08-29 23:44:02

标签: ruby-on-rails ruby ckeditor simple-form

我有一个用于创建/更新Rails应用程序中称为“包装”的产品的表单。 CKEditor的第一个实例保存到数据库并在show视图中工作,而第二个则没有。

为了避免名称冲突,我曾尝试将数据库列名称重命名为其他名称,但这似乎也没有改变。

packs / 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>

packs / 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

1 个答案:

答案 0 :(得分:0)

您需要允许将控制器中的pack_contents参数保存在模型中。