Movatterモバイル変換


[0]ホーム

URL:


LoginSignup
74

Go to list of users who liked

74

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails Markdown サンプルアプリ

Last updated atPosted at 2014-05-26

環境

  • Rails 4.1

サンプル

参考
ASCIIcasts - “Episode 272 - RedcarpetでMarkdown”
masuidrive/open-wripe
vmg/redcarpet

実装

Markdownで記述できるメモアプリを作成したいと思います。

rails _4.1.1_ new note_mdcdnote_mdrails g scaffold Page body:textrake db:migrate

Markdownの処理に用いるgemを追加します。

Gemfile
# markdowngem"redcarpet","~> 2.3.0"
bundleinstall

Markdownの処理を追加します。

app/helpers/application_helper.rb
moduleApplicationHelper@@markdown=Redcarpet::Markdown.newRedcarpet::Render::HTML,autolink:true,space_after_headers:true,no_intra_emphasis:true,fenced_code_blocks:true,tables:true,hard_wrap:true,xhtml:true,lax_html_blocks:true,strikethrough:truedefhtml(markdown)@@markdown.render(markdown).html_safeendend
app/views/pages/show.html.erb
<%= html @page.body %>
74

Go to list of users who liked

74
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
74

Go to list of users who liked

74

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?


[8]ページ先頭

©2009-2025 Movatter.jp