Every repository with this icon (
Every repository with this icon (
Tutorial: Red for Rails
The r is for Rails in red -r
To start turning your JavaScript {color: #C00}Red, navigate to the root directory of your Rails project and execute red -r.
This accomplishes two things:
- it builds the {color: #C00}Red plugin into
vendor/plugins/red; - it creates the
public/javascripts/redfolder.
vendor/plugins/red
Since the nuts and bolts of {color: #C00}Red hide in your gem folders, vendor/plugins/red contains only one tiny, powerful file: init.rb, which tells Rails that {color: #C00}Red is writing your JavaScript from now on.
public/javascripts/red
The public/javascripts/red folder is where you keep your .red application files. In development mode, every time you update a .red file and make a server request, {color: #C80404}Red generates a new .js file in public/javascripts. In production mode, each .js file is generated once and only once, upon the first request after server startup.
public/javascripts/red/lib
Using require statements in {color: #C80404}Red allows you to write your own libraries and access them dynamically. To load the Redshift DOM scripting library , add require 'redshift' to the top of your .red application file. To load a library located at public/javascripts/red/lib/my_library.red, add @require ‘lib/my_library’.
The Command-Line Executable red in Rails
When you work outside of a Rails project, creating filename.red and running red filename will create a file in the same directory called filename.js. The same command from within the root of your Rails project will convert the file public/javascripts/red/filename.red into public/javascripts/filename.js.







