Wire up the CodeMirror assets for your Rails applications.
If you're using Bundler, you can add codemirror-rails to your Gemfile:
Or manually install the codemirror-rails gem:
gem install codemirror-rails
All of the assets from the most latest stable CodeMirror release are vendored so that you can use them with the asset pipeline. At a minimum, you will probably want the following in your application.js and application.css:
//= require codemirror
Additional syntax modes can be added to your application.js:
//= require codemirror/modes/ruby
Additional reusable util components can be added in your application.js:
//= require codemirror/utils/dialog
Additional keymap bindings can be added to your application.js:
//= require codemirror/keymaps/vim
Additional CSS themes can be added to your application.css
//= require codemirror/themes/night
If your project is using precompiling, depending on your method of grabbing files to precompile, you might need to add the below line to your `
application.rb, to get rails to precompile all js, css files used by codemirror. You can also manually whitelist only the files that you use.
config.assets.precompile += ["codemirror*", "codemirror/**/*"]
You can use the generator included with this gem to copy the CodeMirror 2 assets into your Rails 3 public directory.
rails generate codemirror:install
Find a mistake? New version of CodeMirror? Submit a pull request!