Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rail

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rail

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Rail Version Dependency Status Build Status

A light framework for front-end development inspired by Rails. The sole purpose of Rail is to compile assets, and it includes the following components:

Installation

Straightforward

Install the gem:

gem install rail

Create a new project:

rail new my_project

Run Bundler:

cd ./my_project
bundle

Run the server:

rake server

Open http://localhost:3000 in your browser, see “My Project,” and enjoy.

Under the hood, the rail new my_project command creates a new folder in the current directory called my_project and initializes a basic Rail project inside that folder. In this case, MyProject is used as the class name of the project. Feel free to replace my_project with the name of your project.

Manual

Create a Gemfile:

source 'https://rubygems.org'

gem 'rail'

Run Bundler:

bundle

Create three files: config/application.rb, config.ru, and Rakefile. In config/application.rb:

require 'bundler'
Bundler.require(:default)

module MyProject
  class Application < Rail::Application
  end
end

In config.ru:

require_relative 'config/application'

run MyProject::Application.new

In Rakefile:

require_relative 'config/application'

MyProject::Application.load_tasks

Feel free to replace MyProject with the name of your project.

Usage

Rail closely follows Rails. If you know Rails, you already know Rail.

Structure

Organize your code according to the following convention:

  • app/assets/javascripts for scripts,
  • app/assets/stylesheets for styles,
  • app/views for templates,
  • app/helpers for helper modules, and
  • public for other static content.

The templates in app/views/layouts have a special purpose. First, application.html.haml is used for rendering the root of your application (both / and /index.html). Second, any template in layouts is used as a layout for the templates in the subfolder of views that has the same name as the layout. For example, articles/what-is-the-meaning-of-life.html.haml will be rendered in the context of layouts/articles.html.haml provided that the latter has a placeholder for the former via the yield keyword.

Configuration

As with Rails, Rail is configured inside config/application.rb:

module MyProject
  class Application < Rail::Application
    # Gems to look for additional assets
    config.gems << 'googleplus-reader'

    # Assets to precompile when running `rake assets`
    config.precompile << 'application.css'
    config.precompile << 'application.js'
    config.precompile << 'index.html'

    # Compress assets when serving and precompiling
    config.compress = true
  end
end

If config.compress is not specified, it is implicitly set to ENV['RAIL_ENV'] == 'production'.

Commands

Run Rake to see the available tasks:

rake -T
rake assets  # Precompile assets
rake server  # Start server

rake server starts up a Web server; if none is specified in Gemfile, WEBrick will be fired up.

rake assets compiles your assets and stores them in public. You should explicitly tell Rail what to compile as it was shown in the previous section. Note that the server will try to serve from public first, so make sure you delete the precompiled files when you change your code in app.

Examples

Additional usage examples can be found here, here, and here.

Contribution

  1. Fork the project.
  2. Implement your idea.
  3. Open a pull request.

FAQs

Package last updated on 16 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc