I need to be able to generate a model (and later a migration) by executing a Linux shell script.
The script is located directly in the app folder and looks like this:
#!/bin/bash
cd /home/<my_user_profile>/Websites/<my_app_name>
rails g model my_model name:string accepted:boolean [etc...]
The problem is: When I execute the script, the model does not get created. Any ideas why?
To make sure it’s executing in the same context your shell is in, remove the shebang to avoid starting up another
bashwhich may or may not be the same as your current shell.If you’re using rvm/similar, you’d need to either (a) have a default, (b) specify version/gemset, or (c) rely on rvm-like
cdfudgery.Otherwise, should work just fine–it is for me (w/o the shebang, so it’ll use whatever current rvm environment I’m in).