CKEditor 的第二个实例未保存到数据库 | Ruby 在 Rails
Second instance of CKEditor not saving to db | Ruby on Rails
我在 rails 应用程序中有一个用于 creating/updating 产品的表格,称为 "pack"。 CKEditor 的第一个实例正在保存到数据库并在显示视图中工作,但第二个实例不是。
我尝试将数据库列名称重命名为其他名称以防名称冲突,但这似乎也没有任何改变。
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
您需要在控制器中允许 pack_contents
参数,以便将其保存在模型中。
我在 rails 应用程序中有一个用于 creating/updating 产品的表格,称为 "pack"。 CKEditor 的第一个实例正在保存到数据库并在显示视图中工作,但第二个实例不是。
我尝试将数据库列名称重命名为其他名称以防名称冲突,但这似乎也没有任何改变。
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
您需要在控制器中允许 pack_contents
参数,以便将其保存在模型中。