03 Apr Rails console: How to avoid copy-paste formatting issues when you need to run a big script / method
Oftentimes, when you want to run a script in a remote server, you work on that script and then you are having troubles to copy-paste that class, service or method, so in order to not have copy-paste troubles you can do something as follow
You can create a new gist file with your class and then copy the raw version if you already installed the gist cli tool
You can create them privately with
gist -p my_file.rb
Then visit the URL generated and copy the raw version
Afterward, you can ssh the server and in the root path run something like this
curl https://gist.githubusercontent.com/heridev/e3601e768bcf1b8a63bcbf74050e5958/raw/dafce2210cc7272c76f6292661e05371b33fc15c/one_time_scheduling_metrics.rb > one_time_scheduling_metrics.rb
Then go to the rails console
rails console # require that file require_relative 'one_time_scheduling_metrics.rb' # and use it OneTimeSchedulingMetrics.new.my_instance_method
After you are done you can remove that temporal file if you want.
Easy peasy lemon squeezy
No Comments