irb

History not saving

半腔热情 提交于 2019-12-22 00:28:54
问题 Why is my irb history no longer saving? 回答1: It turns out that ruby 1.8.7 introduced a bug whereby finalizers are no longer guaranteed to run. To resolve this, I added the following code snippet to my .irbrc file: require 'irb/ext/save-history' Kernel.at_exit do IRB::HistorySavingAbility.create_finalizer.call(IRB.CurrentContext.instance_variable_get(:@io).send(:binding)) end 回答2: I ran into this with ruby 2.3.7 as well. It was caused by rvm ruby package not having the correct permissions to

How can I send an line in TextMate to an irb process running in an Terminal window?

女生的网名这么多〃 提交于 2019-12-21 20:39:13
问题 I often code with a TextMate window open, and an irb process in a Terminal window adjacent to it. I want to be able to press a key sequence in TextMate which does the following: Copies the current selection, or if there is none, the current line. Pastes it in the topmost Terminal window that is running irb. Presses enter so that the line of code is executed in the irb window. I used this style of interactive development when coding in R and found it very convenient. I'm pretty sure emacs and

Rails: How to cancel current statements in rails console?

删除回忆录丶 提交于 2019-12-21 15:41:11
问题 I'm using Rails 2.3.8 with jRuby for a project. and I regularly use rails console for testing my classes and API, where somehow I experience one problem. when I am working in the Rails console, if I mistakenly input some multi-line commands, is there a way to cancel it somewhere in the middle? e.g.: >> [1,2,3,4].inject(1){ ?> All I found is it will be expecting me to finish the whole completed statement, but all I wanna do is to cancel all current statements. I've tried Ctrl+C, but it didn't

Rails: How to cancel current statements in rails console?

不打扰是莪最后的温柔 提交于 2019-12-21 15:41:04
问题 I'm using Rails 2.3.8 with jRuby for a project. and I regularly use rails console for testing my classes and API, where somehow I experience one problem. when I am working in the Rails console, if I mistakenly input some multi-line commands, is there a way to cancel it somewhere in the middle? e.g.: >> [1,2,3,4].inject(1){ ?> All I found is it will be expecting me to finish the whole completed statement, but all I wanna do is to cancel all current statements. I've tried Ctrl+C, but it didn't

Why Active Record relation is not returned in console?

爱⌒轻易说出口 提交于 2019-12-21 12:58:47
问题 I have finally started upgrading my Rails apps from 2.3.8 to 3.1.0. I was watching RailsCasts (http://railscasts.com/episodes/202-active-record-queries-in-rails-3) about Active Record queries. When I open up the console (rails c) and do query similar to this: articles = Article.order("name") Instead of returning Active Record relations, I see the query executed. What am I doing wrong here? Rails version: 3.1.0 RVM on 1.9.2 Thank you for your help! EDIT: I have added a screenshot from the

How to enable auto completion in Ruby's IRB

喜欢而已 提交于 2019-12-20 08:00:30
问题 When I use Merb's built in console, I get tab auto-completion similar to a standard bash prompt. I find this useful and would like to enable it in non-merb IRB sessions. How do I get auto-completion in IRB? 回答1: Just drop require 'irb/completion' in your irbrc. If that doesn't work try bond, http://tagaholic.me/bond/: require 'bond'; require 'bond/completion' Bond not only improves irb's completion, http://tagaholic.me/2009/07/22/better-irb-completion-with-bond.html, but also offers an easy

Ruby: irb doesn't work on Windows

偶尔善良 提交于 2019-12-19 10:29:12
问题 I've installed Ruby 1.93 in my windows 7 PC using Ruby 1.9.3-p194 one click installer. I can use ruby command to interpret files, but when I type irb it gives me the following error: C:\Users\Acer>irb F:/Programs/Ruby193/lib/ruby/site_ruby/1.9.1/rbreadline.rb:2111:in `expand_path': non-absolute home (ArgumentError) from F:/Programs/Ruby193/lib/ruby/site_ruby/1.9.1/rbreadline.rb:2111:in `_rl_read_init_file' from F:/Programs/Ruby193/lib/ruby/site_ruby/1.9.1/rbreadline.rb:2094:in `rl_read_init

rails console with wirble?

非 Y 不嫁゛ 提交于 2019-12-19 06:56:46
问题 How do i use rails console with the wirble gem? I originally had the code that wirble gives you and put it in my .irbrc At this point, irb worked fine with wirble (color highlighting), but when i would start rails console it would give an error about wirble and halt. I changed the irbrc code so it doesnt halt but continues on error, this at least gets rails console load but theres no color highlighting. Any ideas what i should put? this is in my irbrc begin # load and initialize wirble

How to create a custom method for the rails console?

南笙酒味 提交于 2019-12-19 04:02:01
问题 When I'm using the Rails console in Ubuntu for a long session I define the clear method: def clear; system 'clear' end So when my console is getting dirty the only thing I have to do is type clear and the console gets cleared. I would like to use this function without to re-type it every time. Thanks in advance. 回答1: Just put it in the ~/.irbrc file. It gets loaded every time you run irb or rails console . The Rails console is just irb with your Rails application environment loaded. Find more

Can't enter Umlauts in Ruby 1.9.3 IRB

♀尐吖头ヾ 提交于 2019-12-18 13:09:50
问题 I am experiencing very strange behavior in Ruby 1.9.3's IRB with Mac OS 10.7.3 When I try to enter an Umlaut, it's escaped in the prompt and looks like this (I entered "ü" on the keyboard) irb(main):001:0> "\U+FFC3\U+FFBC" What's super strange is this: irb(main):001:0> "\U+FFC3\U+FFBC".length => 0 Of course, the character isn't displayed either: irb(main):001:0> "\U+FFC3\U+FFBC" => "" Does anyone know what's going on here or how to fix this? 回答1: Victor Moroz didn't quite give the definitive