LoginSignup
0
3

More than 5 years have passed since last update.

Ruby on RailsでACEエディタを使う

Last updated at Posted at 2017-06-11

RailsでACEエディタを使う

Railsでオープンソースのエディタであるaceを使用するメモ
ACEエディタについて

erbでaceのライブラリを読み込む

ace.html.erb
<%= javascript_include_tag "https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js", :cache => "cached_all" %>
    <div id="editor"></div> <%# エディタを読み込むdivタグ %>
<%= javascript_include_tag "ace" %>  <%# ace.js.coffeeを読み込む %>

CoffeeScriptにACEの設定を記述する

ace.js.coffee
editor = ace.edit("editor")
editor.$blockScrolling = Infinity

editor.setTheme("ace/theme/monokai")
editor.getSession().setMode("ace/mode/html")

最後にace.js.coffeeをプリコンパイルするように記述

config/initializers/assets.rb
Rails.application.config.assets.precompile += %w( *.js )
0
3
0

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
0
3