# node-rails

> Load js and coffee in assets of Rails3

Latest version **0.1.0** (published 2012-02-28) · 0 weekly downloads

## Install

```sh
npm install node-rails
pnpm add node-rails
yarn add node-rails
bun add node-rails
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2012-02-28 |
| First published | 2012-02-28 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Yuku Takahashi |
| Maintainers | taka84u9 |

## Links

- npm: https://www.npmjs.com/package/node-rails
- npm.io page: https://npm.io/package/node-rails

## Recent versions

- 0.1.0 (latest) — 2012-02-28

## README

# node-rails

Rails js and coffee loader for node.js.

## Installation

Just copy rails.js.

## Introduction

Suppose that `app/assets/javascripts/blog.js` and `app/assets/javascripts/author.js` are:

```javascript
// app/assets/javascripts/blog.js
//= require author

blog = {
    author: author
};
```

```javascript
// app/assets/javascripts/author.js
author = {
    name: 'Yuku Takahashi'
    email: 'taka84u9@gmail.com'
};
```

Then you can load it as follows:

```javascript
// tmp.js
rails = require('node-rails');
window = rails.load('blog');

console.log(window.blog);
```

When execute `tmp.js`:

```
$ node tmp.js
{ author: { name: 'Yuku Takahashi', email: 'taka84u9@gmail.com' } }
```

## Useage

I developed this module to write JavaScript test cases using vows:

```coffeescript
# test.coffee
vows   = require 'vows'
assert = require 'assert'
rails  = require 'node-rails'

blog = rails.load('blog').blog

vows
  .describe('Test cases for blog object')
  .addBatch
    'blog':
      topic: -> blog
      'name of author is "Yuku Takahashi"': (topic) ->
        assert.equal topic.author.name, 'Yuku Takahashi'
      'email is "taka84u9@gmail.com"': (topic) ->
        assert.equal topic.author.email, 'taka84u9@gmail.com'
  .export module
```

```
$ vows --spec test.coffee
♢ Test cases for blog object

  blog
    ✓ name of author is "Yuku Takahashi"
    ✓ email is "taka84u9@gmail.com"
 
✓ OK » 2 honored 
```

---
_Source: https://npm.io/package/node-rails · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
