Equivalence of Rails console for Node.js

Create your own REPL by making a js file (ie: console.js) with the following lines/components: Require node’s built-in repl: var repl = require(“repl”); Load in all your key variables like db, any libraries you swear by, etc. Load the repl by using var replServer = repl.start({}); Attach the repl to your key variables with replServer.context.<your_variable_names_here> … Read more

Truncate table(s) with rails console

The accepted answer only works if you need to recreate the whole database. To drop a single table (with the callbacks) and to get the IDs to start from 1: Model.destroy_all # Only necessary if you want to trigger callbacks. ActiveRecord::Base.connection.execute(“TRUNCATE #{table_name} RESTART IDENTITY”) If you are using Sqlite, it does not support truncate so … Read more

Rails Console: reload! not reflecting changes in model files? What could be possible reason?

reload! only reloads the latest code in the console environment. It does not re-initialize existing objects. This means if you have already instantiated any objects, their attributes would not be updated – including newly introduced validations. However, if you create a new object, its attributes (and also validations) will reflect the reloaded code. more here