如何在 Rails 环境中运行 Ruby 文件? [英] How do I run a Ruby file in a Rails environment?

查看:44
本文介绍了如何在 Rails 环境中运行 Ruby 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Rails 环境的上下文中运行 Ruby 文件.rails runner 几乎可以做我想做的事情,但我只想给它文件名和参数.我很确定这是可能的,因为我以前做过.有人能提醒我怎么做吗?

I want to run a Ruby file in the context of a Rails environment. rails runner almost does what I want to do, but I'd like to just give it the file name and arguments. I'm pretty sure this is possible since I've done it before. Can someone remind me how to do this?

推荐答案

最简单的方法是使用 rails runner,因为您不需要修改脚本.

The simplest way is with rails runner because you don't need to modify your script.

http://guides.rubyonrails.org/command_line.html#rails-runner

就说rails runner script.rb

这篇关于如何在 Rails 环境中运行 Ruby 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆