开发者

Table format in Hirb for .where Rails 3 queries

开发者 https://www.devze.com 2023-01-14 21:07 出处:网络
I am using http://tagaholic.me/hirb/ to format AR queries in console with pretty, MySQL like table views.

I am using http://tagaholic.me/hirb/ to format AR queries in console with pretty, MySQL like table views.

The problem is, that by default Rails 3 .where queries, reaturned as ActiveRecord::Relation arent displayed in a table format. With imported table method everything is formatted properly. How to set defa开发者_运维技巧ult display to table in Hirb for a given object type?


It works for me with hirb version 0.3.5 and Rails 3.0.1.

Check your ~/.irbrc file doesn't use ENV['RAILS_ENV'] to determine whether to load Hirb, because Rails 3 no longer sets that. Use this instead:

# ~/.irbrc
Hirb.enable if defined?(Rails)

If using RVM, add it to your Gemfile to ensure hirb is correctly loaded:

# Gemfile
gem 'hirb', :require => nil


Or you can use richrc RichRC (Rich Rails Console) is a customization tool for Rails 3 console.

sudo gem install richrc hirb wirble

make a new alias in ~/.bash_profile

alias railsc="richrc"

source ~/.bash_profile

insted of rails c use:

railsc

website: richrc

0

精彩评论

暂无评论...
验证码 换一张
取 消