In my controller, a function runs a shell command. I’m having a hard time to locate the script in the commad. For example, in my controller I have this:
def find_usage
command = ‘ruby usage.rb’
#{command}
end
My question is where to put that usage.rb file and how to reference it without hard code the entire path. It works when I hard code the path as /home/user/xyz/usage.rb, but I don’t think it’s right to do.
You could stuff it into /script and then reference
RAILS_ROOT/script/usage.rbin your code.RAILS_ROOTis a constant that contains the absolute path to your application.