Search code examples
ruby-on-railsrubyckeditorsimple-form

Second instance of CKEditor not saving to db | Ruby on Rails


I have a form that I'm using for creating/updating products known as a "pack" in my rails application. The first instance of CKEditor is saving to the db and working in the show view but the second isn't.

I've tried renaming the db column name to something else in case it was a conflicting name, but that didn't seem to change anything either.

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>

Thanks in advance, I appreciate the help!

Update:

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

Solution

  • You need to permit the pack_contents parameter in the controller, in oder for it to be saved in the model.