自动包含在Rails控制台中 [英] Auto include in Rails Console

查看:106
本文介绍了自动包含在Rails控制台中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现自己必须输入(例如)

I find myself having to type (for example)


包含PathHelper

include PathHelper

每次加载Rails控制台时。

every time I load the Rails Console.

有没有办法配置Rails控制台自动包含某些模块?

Is there a way to configure the Rails console to automatically include certain modules?

推荐答案

如果你还在寻找答案,这就是我的工作,
我创建了一个文件〜/ .irbrc 其中您将要自动加载的所有代码放在rails控制台中。

If you are still looking for an answer, this is what I do, I created a file ~/.irbrc in which you put all the code you want to be auto loaded in your rails console.

这是内容我的文件:

require "awesome_print"
include Rails.application.routes.url_helpers

AwesomePrint.irb!
def y(obj)
  puts obj.to_yaml
end

这篇关于自动包含在Rails控制台中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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