I am trying to attribute the time param with .to_date to generate the proper comparison
Organization.find(1140).events.all(:conditions => ["time < ?", Time.now.beginning_of_day]).blank?
How would I do that? I tried this :
Organization.find(1140).events.all(:conditions => [time.to_date < ?, Time.now.beginning_of_day]).blank?
And tha...
Is there a way to "reload" or "refresh" a rubygem in memory? As i'm playing in irb, occasionally I like to modify my gem files, and if i require the same gem, it does not update into memory and gives the output "false". Currently I have to exit IRB, get back into IRB and then require the gem again, there has to be a better way...what is ...
What is the easiest way to return an array in random order in Ruby?
Anything that is nice and short that can be used in an IRB session like
[1,2,3,4,5].random()
# or
random_sort([1,2,3,4,5])
...
Is it possible to create a CSV file right out of the command line in IRB or elsewhere with a one-time use on it. Say, I just need a CSV file with all my user's first name on it.
Can I create that without setting up any architecture?
...
I have Users . Users have_many :organizations
If I do:
User.find(:all).select {|u| u.organizations.first.name }
it returns with:
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.name
from (irb):33
from (irb):33:in `select'
from (irb):33
Long story short:
I am trying to find t...
I have a simple call
JSON.parse(Panda.get("/videos/#{self.panda_video_id}/encodings.json"))
Which returns :
can't convert Array into String
This is because the Panda.get("/videos/#(self.panda_video_id}/encodings.json") call returns an array in the new Panda 1.0.0 gem.
I also tried :
JSON.parse(Panda.get("/videos/#{self.panda_vi...
I've found some online interactive Javascript editors, but I wonder if there is a local equivalent as a gem that lets me test Javascript just like IRB and Rails console in Mac?
...
I'm developing a ruby app with Vim in one screen, and in another I'm using irb to test the code I'm writing in Vim.
For the sake of this example, we'll say there are only 2 irb commands to test the code that I've written, a load and a method call.
Generally, it's more than 2 commands - if its just 2 I would tap the up arrow twice and hit...
Hello,
I'm trying to update irb on my OS X 10.5 macbook:
$ irb -v
irb 0.9.6(09/06/30)
I'm currently learning Ruby and was following the "Why's Poignant Guide to Ruby" and on this page: http://mislav.uniqpath.com/poignant-guide/book/expansion-pak-1.html they mention auto-completion in irb requires version 1.8 of irb.
I'm not sure ent...
In Ruby main, you can embed IRB inside of a Ruby script as described here. Is there a way to do something similar with IIRB inside an IronRuby script?
...
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 default display to table in Hirb ...
I'm a bit confused about how paths work with gems. Here's the core of my confusion:
>> require 'rubygems'
=> false
>> Gem.available?('money')
=> true
>> require 'money'
LoadError: no such file to load -- money
from (irb):3:in `require'
from (irb):3
from /usr/bin/irb:12:in `<main>'
>> Gem.available?('pony')
=> fa...
I'm trying to include a source code file when I run irb but irb is unable to find it.
For example, say I am in the following directory in terminal:
/dan/rubyapp/
Assume I have a file named "firstapp.rb" in /dan/rubyapp/
I startup irb and from the irb prompt I type
> require "firstapp.rb"
but the file can't be found. If I type "Di...
Hi,
I have just installed rvm today and it looks really handy/powerful.
I think I am getting the hang of it, but...
When using an rvm installed ruby, and running irb, when I require an installed gem, something, like 'rvm', I get:
> kimptoc$ rvm use 1.8.7
Using /Users/kimptoc/.rvm/gems/ruby-1.8.7-p302
> kimptoc$ gem list
*** LOCAL ...
Say I have a file named test1.rb with the following code:
my_array = [1, 2, 3, 4 5]
Then I run irb and get an irb prompt and run "require 'test1'. At this point I am expecting to be able to access my_array. But if I try to do something like...
puts my_array
irb tells me "my_array" is undefined. Is there a way to access "my_array"
...
Is there a way to display Active Record results in table format in the script/console environment?
...
In the python world, there are a number of alternative python interpreters that add cool additional features. One particularly useful example is bpython, which adds dynamic syntax highlighting, automatically pulls documentation, and displays live autocomplete information. In the Ruby world, I have yet to uncover any projects which add to...
I'm having a really noob problem with importing files in Ruby. I'm making a Ruby app in Windows XP. All the class files for the app are in "C:/Documents/Prgm/Surveyor_Ruby/lib". But when I require a file in another file, neither ruby nor irb can find the required file.
The current directory's contents:
C:\Documents\Prgm\Surveyor_Ruby\l...
Hi Inside rails console you can get the result of the previous operation with _ Is there any way to do such a thing inside ruby program?
...
Using Rails3 and Ruby 1.9.2, I am new, just learning Ruby/Rails--
When I run irb I end up with irb(main):001:0> which is fine.
However when I run rails console I also end up with irb(main):001:0> and I thought, based on the book I'm reading and online tutorials that I should be seeing >>. Is the Rails Console I'm thinking of a gem that...