Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dolsem/rails-console.js
https://github.com/dolsem/rails-console.js
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dolsem/rails-console.js
- Owner: dolsem
- License: mit
- Created: 2022-05-02T04:08:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-05-16T05:49:04.000Z (over 2 years ago)
- Last Synced: 2024-12-02T17:23:30.863Z (about 1 month ago)
- Language: TypeScript
- Size: 203 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
rails-console.js
===========================Rails interface in Node.js via Rails console
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![License: MIT][license-image]][license-url]# ⚙ Install
```bash
# npm
npm i rails-console# yarn
yarn add rails-console
```# 🔍 Usage
```js
const { RailsConsole } = require('rails-console');async run() {
const rc = new RailsConsole();
// Or:
const rcWithOptions = new RailsConsole({
cwd: path.resolve(__dirname, 'rails-app'), // Optionally specify directory where to start rails console
});// Wait for the rails console process to start
await rc.start();// Get application name
const result = await rc.send('Rails.application.engine_name.gsub(/_application$/,"")');
if (result.success) {
console.log(`Name of the Rails app: ${result.returnValue}`);
} else {
console.log(`Command returned an error: ${result.error}`);
}
if (result.raw.stderr) {
console.log(`Command output warnings: ${result.raw.stderr}`);
}// Update an ActiveRecord item
await rc.send('User.find(1).update(name: "First User")');// Stop the process
rc.stop();
}
```# ️❤️ Contributing
Every contribution is really welcome!
If you feel that something can be improved or should be fixed, feel free to open an issue with the feature or the bug found.
If you want to fork and open a pull request (adding features or fixes), feel free to do it.
Read the [contributing guidelines](./CONTRIBUTING.md)
# 📃 Licence
Read the [licence](./LICENCE)
[npm-image]: https://img.shields.io/npm/v/rails-console.svg
[npm-url]: https://npmjs.org/package/rails-console
[downloads-image]: https://img.shields.io/npm/dm/rails-console.svg
[downloads-url]: https://npmjs.org/package/rails-console
[license-image]: https://img.shields.io/badge/License-MIT-blue.svg
[license-url]: https://opensource.org/licenses/MIT