I am currently trying to figure out if it is possible to run multiple commends within one line on a rails console through Unix shell or within a ruby script.
For Example:
exec('echo p = Product.first;b = Billing.first|rails c')
When I tried something similar to the example, it would always try to execute the two commands before launching console.
Hope this make sense and appreciate any help I can get.
Thanks in advance!
Yes you can do this
From a unix shell prompt:
echo 'p = Product.first; b = Billing.first' | rails c
From the rails console itself, or a ruby script I guess:
exec(%Q{echo 'p = Product.first; b = Billing.first' | rails c})
It's probably worth asking why you want to do this though. Could you use a rake task?
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments