简体   繁体   English

希伯不起作用

[英]Hirb doesn't work

I have tried a few different tutorials for Hirb but rails c is stubbornly refusing to load automatically using .irbrc. 我为Hirb尝试了一些不同的教程,但是rails c固执地拒绝使用.irbrc自动加载。

Here's what I've been doing. 这就是我一直在做的事情。

# From app directory
mate .irbrc

# Added to .irbrc
require 'rubygems'
require 'hirb'
extend Hirb::console
Hirb::View.enable

rails c development / rails c production / rails c test
Works as expected

rails c
User.last # Doesn't work
Hirb::View.enable
  true
User.last # Does work

The odd thing is this: when I load rails c development , rails c production or rails c test , Hirb starts working straight away. 奇怪的是:当我加载rails c developmentrails c productionrails c test ,Hirb立即开始工作。 But, running rails c and it needs Hirb::View.enable first. 但是,运行rails c并且首先需要Hirb::View.enable I find this behavior very strange - could you help shed some light? 我觉得这种行为很奇怪 - 你能帮忙解决一些问题吗? Thank you. 谢谢。

The first argument sets ENV['RAILS_ENV']. 第一个参数设置ENV ['RAILS_ENV']。 From what you've said, you could get around this quirk by adding this to your ~/.bashrc: 根据你所说的,你可以通过将它添加到你的〜/ .bashrc来解决这个问题:

export RAILS_ENV='development'

However if you want to solve the root of your problem, you should mention what your Gemfile is (you do have hirb in your Gemfile, right?). 但是,如果你想解决问题的根源,你应该提一下你的Gemfile是什么(你的Gemfile中有hirb,对吧?)。 Also is your .irbrc local to your application? 你的应用程序本地也是你的.irbrc吗? If so, how is it automatically loaded (probably by something in your ~/.irbrc)? 如果是这样,它是如何自动加载的(可能是你的〜/ .irbrc中的东西)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM