3

I'm writing an executable shell script that does something in the rails console using rails runner. How do I see the results of the ruby command made and print them to the screen.

I tried running the script with -v for verbose but I still wasn't able to see what occurred.

#!/bin/sh
sudo rails runner "Model.print_something"
2
  • 1
    What happens when you execute sudo rails runner "Model.print_something" directly from terminal? Commented Jun 30, 2016 at 19:04
  • 1
    I guess you want to use rails console instead, since rails runner says runner runs Ruby code in the context of Rails non-interactively. Commented Jul 1, 2016 at 8:38

1 Answer 1

6

Use puts
sudo rails runner "puts Model.print_something"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.