KusGrus
KusGrus

Reputation: 85

Run script Ruby on Rails

I have a set of commands that I run in the bin/rails console, for example:

AppConfig.settings.captcha.enable = false
success = user.sign_up
etc ...

Can I make a script like bin/bash to execute all commands at once? (I would like it to be a executable file, since I want to change the input data in it)

Upvotes: 1

Views: 911

Answers (1)

Timur Shtatland
Timur Shtatland

Reputation: 12337

You can put the commands into a file (script), add the shebang line (#!/usr/bin/env ruby), make the file executable and run it from the command line like so:

#!/usr/bin/env ruby
# require ... (load the libraries here)
...
AppConfig.settings.captcha.enable = false
success = user.sign_up
#etc ...
# Make executable
chmod u+x my_script.rb

# Run the script
/path/to/my_script.rb

Upvotes: 1

Related Questions