我第一次使用showdown-rails
gem,並且在出現時遇到了一些麻煩。我按照GitHub頁面的指示運行了gem的安裝,其中包括我的application.js
文件,其中包含//= require showdown
。我使用下面的代碼使用它在一個_form
部分我wikis#edit
/wikis#new
頁:攤牌未出現在Rails應用程序中
<%= form_for(@wiki) do |f| %>
<%= f.label :title %><br>
<%= f.text_field :title, class: "form-control" %>
<%= f.label :body %><br>
<%= f.text_area :body, class: "form-control", style: "height: 250px", id: "wiki_body" %>
<% if current_user.admin? || current_user.premium? %>
<%= f.label :private, class: 'checkbox' do %>
<%= f.check_box :private %> Make Wiki Private
<% end %>
<% end %>
<% if @wiki.private? %>
<%= f.label "Add Collaborators", class: 'checkbox' %>
<div style="height: 80px; overflow: scroll; border: thin grey solid; padding-left: 10px">
<% @users.each do |user| %>
<%= check_box_tag "wiki[user_ids][]", user.id, @wiki.users.include?(user) %>
<%= user.name %><br>
<% end %>
</div>
<% end %>
<script>
var converter = new showdown.Converter();
$('#wiki_body').on('keyup', function() {
var mdown = $(this).val();
$('#wiki_preview').html(converter.makeHtml(mdown));
});
</script>
<div class="well" style="margin-top: 20px">
<p id="wiki_preview"></p>
</div> <!-- showdown well -->
<div class="text-center">
<%= f.submit "Create Wiki", class: "btn-custom" %>
</div> <!-- text-center -->
<% end %>
顯示良好,但實際文本Showdown
應該呈現永遠不會出現。這是我第一次使用寶石,所以我不確定哪裏出錯。任何人都可以在這裏指出我的錯誤?