2017-03-03 22 views
0

喜來輔助..回報率 - ActiveAdmin與CKEDITOR顯示了這個HTML標籤

我已經看過不斷處處得到這個工作,但沒有成功。

設置: - ActiveAdmin與CKEDITOR中的文章(博客文章)

問題: - 我可以輸入文本,並在體內圖像的CKEditor的,但是當我去articles.html頁它吐出出所有的html標籤和源代碼。

Article.rb(活性管理下)

permit_params:標題,:旗幟,:article_icon,:介紹,:主體,

:section 
    form do |f| 
    f.semantic_errors *f.object.errors.keys 
    f.inputs do 
     input :title 
     input :banner, :required => true, :as => :file 
     input :article_icon, :required => true, :as => :file 
     input :introduction 
     input :body, :as => :ckeditor 
     input :section, as: :select, collection:Article.sections.keys 
     # input :format_text 
    end 
    actions 
    end 

development.rb

config.assets.precompile += %w(ckeditor/*) 

初始化for active_admin.rb

config.register_javascript 'ckeditor/init.js' 

的Gemfile

gem 'activeadmin_ckeditor' 

Article.html

<% article_id = "article-id-#{article.id}" %> 
     <div class="col-md-12"> 
      <input type="checkbox" class="read-more-state" id="<%= article_id %>" /> 
      <p class="read-more-wrap"><span class="read-more-target"><%= article.body %></span></p> 
      <label for="<%= article_id %>" class="read-more-trigger"></label> 

     </div> 

(該article.body應顯示爲無標籤) 我還上傳了圖片,在這裏所示的情況。

<p>body content goes here<img alt="" src="/ckeditor_assets/pictures/1/content_proportionspace_fabioaraujo.jpg" style="width: 800px; height: 450px;" /></p> 
  • 我要如何消除這種因此它顯示沒有標籤和src圖片?
  • 也嘗試過rake預編譯(但我的公共/ cdkeditor_assets只有一個子文件夾的圖片)不應該有更多的文件夾和資產?

希望有人能幫助。 非常感謝,非常感謝。

+0

@HarleenKaurArora隱藏在開啓和關閉的內容html_safe - 那是什麼意思。 .html_safe的作品,雖然它打破了更多的觀點,並查看較少的行動。 –

+0

@HarleenKaurArora - 文件已經名爲articles.html.erb,我的所有html文件都是.erb文件 –

+0

是的,它可以工作並顯示所有內容,但它會創建一個關於div動作的新問題 - 除非用戶點擊'查看更多'。使用原始/安全模式將刪除「讀取更多狀態」的div動作並顯示完整內容 –

回答

0

你必須使用.html_safe呈現HTML標籤

<div class="col-md-12"> 
     <input type="checkbox" class="read-more-state" id="<%= article_id %>" /> 
     <p class="read-more-wrap"><span class="read-more-target"><%= article.body.html_safe %></span></p> 
     <label for="<%= article_id %>" class="read-more-trigger"></label> 

    </div> 

形象的事,我不知道。

+0

這工作完美.html_safe,並進一步呈現圖像,但這進一步打破了內容的觸發器操作...我通常有一個按鈕來查看更多 - 但與.html_safe這只是離開容器打開 –

0

此問題已通過使用js按鈕類操作來解決,而不是內置html和css操作以獲取更多狀態。

內容正確顯示與根據按鈕狀態