irb

Simple IRB Question regarding Count

I have a class called Deal. Deal has vote_scores. I would like to see how many vote_scores are in Deal that are greater than 2. My guess : for vote_scores > 2 in Deal count end Doesn't really work :D Edit: I tried everyone's ideas. But note that : Deal.vote_scores Doesn't work because vote_scores is not an attribute ...

How do I compile irb from source on Ubuntu?

I would like to compile irb from source without any optimizations so I can get more information while stepping through (interpreter) code using gdb. I have successfully compiled ruby 1.9.1 without problems, but I cannot find any documentation regarding irb. I believe that irb is included in the ruby 1.9 source, but have not been able t...

Problems installing rdoc, irb, bluecloth, chronic on fedora 12

Hello, What do these errors mean? [root@localhost config]# gem install bluecloth Building native extensions. This could take a while... ERROR: Error installing bluecloth: ERROR: Failed to build gem native extension. /usr/bin/ruby extconf.rb can't find header files for ruby. Gem files will remain installed in /usr/lib64/ruby/g...

Rubygems Path Question

I am trying to run the following ruby code from IRB but am unable to require the gmail gem. require 'rubygems' require 'gmail' gmail = Gmail.new("user", "pass") Here's the IRB output: Johnny-Goodmans-MacBook-Pro:gmail johnnygoodman$ irb >> require 'rubygems' => false >> require 'gmail' NameError: uninitialized constant Gmail ...

Newly installed Ruby gems not showing up in $LOAD_PATH

I'm using MacPorts in order to manage my Ruby/Rails/Gems installations. Recently after doing a gem install wirble, wirble fails to load when I start an instance of irb. Here's the output: $ irb --simple-prompt Couldn't load Wirble: no such file to load -- wirble The Wirble gem doesn't show up in my $LOAD_PATH: >> puts $: /opt/local/l...

Anything like bpython for Ruby?

IRb is pretty plain compared to bpython, even when using wirble. Is there any ruby equivalent of bpython? ...

IRB and large variables?

How can I print a large variable nicely in an irb prompt? I have a variable that contains many variables which are long and the printout becomes a mess to wade through. What if I just want the variable names without their values? Or, can I print each one on a separate line, tabbed-in depending on depth? ...

'script/console test' with spork and rspec not loading the whole environment?

I'm trying to load up console to interact with some of my rspec mocking helpers. I expected that running script/console test would load an env similar to when I run spec. However, this doesn't appear to be the case. It looks like spec_helper is never loaded. Or, if it is, it's not actually running through the logic because spork has poll...

Can I use what I wrote on the shell (bash, cmd, irb, etc) in a script automaticaly?

The general idea is pretty simple, I want to make a script for a certain task, I do it in the shell (any shell), and then I want to copy the commands I have used. If I copy all the stuff in the window, then I have a lot of stuff to delete and to correct. (and is not easy to copy from shell) Resume: I want to take all the things I wrote...

How do I update all attributes of a class in IRB?

Objective: I would like to reset the array attribute of all objects in a class to []. The way they started. My attempt: > Deal.find(:all).update_attribute('votes', []) Outcome: Returns an error. How would you do this? ...

Writing a simple conditional statement in IRB

I am looking up all Organizations with the url "http://", and updating their attributes to "". My attempt: Organization(:all).select { |o| o.url = "http://" ? o.update_attribute("url","")} Which returns a compile error: SyntaxError: compile error (irb):2: syntax error, unexpected '}' from (irb):2 Any ideas? ...

Is it possible to titleize in IRB?

I tried this : User.find(1).update_attribute('first_name', '#{first.name.titleize}') => /#{first.name.titleize} I am not sure any other way to do this. Many thanks ...

Where does the variable "p" get it's value from in ruby if it's not defined explicitly?

Question: Where does p get it's value from below and why does it happen? Consider this irb session: me@somewhere:~$ irb irb(main):001:0> a NameError: undefined local variable or method `a' for main:Object from (irb):1 irb(main):002:0> foo NameError: undefined local variable or method `foo' for main:Object from (irb):2 irb(main)...

NoMethodError (set_result) in SQLite3 when running Geocommons Geocoder using irb on Mac OS X 10.5.8

Has anyone here ever encountered the following error after installing and attempting to run the Geocommons geocoder on Mac OS X 10.5.8? This is my exact output from the Terminal window from the point at which I started irb: $ irb >> require 'geocoder/us' => true >> db = Geocoder::US::Database.new("/opt/tiger/orangeca.db") => #<Geocoder...

edit with vim in irb

Hi, I'm trying to set up editing within irb using vim as described in this vimcast: http://vimcasts.org/episodes/running-vim-within-irb/ I did the gem install interactive_editor and it seemed to install the gem to /home/me/.gems/ruby/1.9.1/gem/interactive_editor, and I also edited my .irbrc file and added: require 'rubygems' require '...

Discover the file ruby require method would load?

The require method in ruby will search the lib_path and load the first matching files found if needed. Is there anyway to print the path to the file which would be loaded. I'm looking for, ideally built-in, functionality similar to the which command in bash and hoping it can be that simple too. Thanks. ...

Setting bash aliases for IRB ?

So every morning to boot up my server , I need to do the following tasks.. >> sunspot-solr stop >> sunspot-solr start >> script/console >> Organization.reindex >> Event.reindex >> Deal.reindex >> exit >> script/server Is there any way I can make a shortcut in my ~/.profile as an alias to perform all this for me without me typing it ev...

How can I colorize logger output in a rails 3 console

How can I colorize and possibly bold the output from Rails.logger in my rails3 application? ...

How to force a vertical table or limit columns in Hirb?

Hi, I want to display few active records in rails console, I have Hirb enabled. The table is narrow enough to be displayed (so Hirb uses standard, horizontal table) but columns are so narrow that content is completely unreadable. Do you have any idea what I could do about it? Displaying only few columns would be great (I have records in...

Object refuses to save changes in Rails IRB

Good morning all, I've got an association that I'm working on, and for some reason, I can't get it to save changes to the object in question when I'm debugging it in IRB. I was wondering if anyone could point out my problem. Here is the association: class User < ActiveRecord::Base has_and_belongs_to_many :affiliates has_one :mana...