3

I have tried a few different tutorials for Hirb but rails c is stubbornly refusing to load automatically using .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. But, running rails c and it needs Hirb::View.enable first. I find this behavior very strange - could you help shed some light? Thank you.

sscirrus
  • 55,407
  • 41
  • 135
  • 228
  • I have the same problem if someone could follow this link for help :) http://stackoverflow.com/questions/14473802/hirb-doesnt-work-at-all-in-rails-console **thank you very much** – jramby Jan 23 '13 at 06:58

1 Answers1

2

The first argument sets ENV['RAILS_ENV']. From what you've said, you could get around this quirk by adding this to your ~/.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?). Also is your .irbrc local to your application? If so, how is it automatically loaded (probably by something in your ~/.irbrc)?

cldwalker
  • 6,155
  • 2
  • 27
  • 19