ruby

Installing Ruby-Gnome2 on Ubuntu with RVM

I have RVM running and it is working brilliantly, but I can't seem to figure out how to install ruby-gnome2. I have followed the steps on this tutorial, which are: rvm use 1.9.1 # I use 1.9.1 which should work with ruby-gnome2 wget http://downloads.sourceforge.net/ruby-gnome2/ruby-gnome2-all-0.19.4.tar.gz tar zxf ruby-gnome2-all-0.19.4....

Rubygems permissions problem in Leopard.

I've been struggling to get a rails development environment. I've installed ruby and rubygems through macports, and they are both running from /opt/local/bin. But apparently some permissions are hosed - I've gone through and chmodded all directories I can find related to rubygems, but I'm still unable to run rubygems without a sudo. At t...

Rails order by associated object number

Hey, The title of this question might be a bit off but its the closest I could get to what I am trying to do. I have a Products model which has_many Comments. I am looking to come up with a way to grab the top 10 Products with the most comments. Is this possible? At the moment I have: Product.find(:all, :limit => 10) This gets me...

Sharing global references among jruby threads and inside Rack application

I'm trying to create a Stats counter (similar to the one in ostrich for scala by Twitter) but having a hard time making sure that all my threads have access to this. My Stats class is defined like this: class Stats @@counters = {} .. accessors .. def self.incr(counter, amt = 1) if !@@counters[counter] @@counters[coun...

Ruby Environment Variables

Hello, I am experiencing a strange problem with Ruby and Environment variables. I am currently on a x64 machine running Windows Server 2008 R2 If I do the following in ruby: puts ENV['PROCESSOR_ARCHITECTURE'] I expect to see AMD64, however, Ruby is displaying x86 If I do: echo %PROCESSOR_ARCHITECTURE%, in the command prompt, I am gr...

Machinist for Non-ActiveRecord Models

Is it possible to use Machinist to create blueprints for non-activerecord models? Seems to generate an error no matter what I try! If this is impossible with Machinist, is there another fixture generating gem that can do it? I've also read that Factory Girl has issues with this. ...

OAuth and HTTParty

Is it possible to use OAuth with HTTParty? I'm trying to do this API call, but, contradictory to the documentation, it needs authentication. Before you say "Use a Twitter-specific Gem", hear me out--I've tried. I've tried twitter, grackle, and countless others, but none support this specific API call. So, I've turned to HTTParty. So, h...

Google Apps and Open ID Authentication in Rails - Security

I'm moving an app to use only Google Federated Login (OpenID) for an application (we use google apps for everything and feel it would be easier to combine user management there). While I can successfully login and create users, my thoughts are now on security... When a user logs in I only have a "Log In" button - nothing else. The sit...

Nokogiri html parsing question

Hello, I'm having trouble figuring out why I can't get keywords to parse properly through nokogiri. In the following example, I have the a href link text functionality working properly but cannot figure out how to pull the keywords. This is the code I have thus far: ..... doc = Nokogiri::HTML(open("http://www.cnn.com")) doc.xpath('/...

Hash.each question

Hash.each return an array [key, value] but if i want an hash? Example: {:key => value } ...

Time.now in activerecord format

I need it for an unit test... how to get a time.now in the same format as active record returns for a datetime field? ...

Rails user queue system?

I would like to create a Rails app that would allow users to control the serial port of the host server. To keep some order to the serial commands, I would like to have some sort of queue system that would only allow one user at a time to issue commands, with a time limit. When their time expires, the next user in the queue is given cont...

Anything better than ruby alchemy for extracting keywords?

I've currently written an algorithm in Ruby based on the arc90 readability code to extract an article from a web page. Now that I have the article, I want to extract keywords and specific information from it (names, author, etc) I heard Alchemy was a great ruby gem for doing this though it consumes a lot of resources. Are there any bet...

Liquid view_paths error

I'm trying to deploy my RoR app. It seems to be working fine on my development machine when RAILS_ENV is set to development. However, when I put it on the production server and set it into production mode I get the following error after navigating to the start page: => Booting Mongrel => Rails 2.3.8 application starting on http://0.0....

XPath select node with periods

I have an XML document where some of the nodes have a . in their name. <com.site.blah> <id>asdkjasd</id> <com.site.testing> <name>test</name> </com.site.testing> </com.site.blah> If I do @doc.search("/*/id").first.xpath it returns /com.site.blah/id, but if I then do: @doc.search("/com.site.blah/id").first.inspect it r...

Lisp as an internal Ruby DSL?

I've been able to find: a) Lisp interpreters written Ruby (i.e., an external DSL) http://onestepback.org/index.cgi/Tech/Ruby/LispInRuby.red b) Prolog as a Ruby DSL http://www.kdedevelopers.org/node/2369 c) Discussion of Ruby "as" a Lisp http://www.randomhacks.net/articles/2005/12/03/why-ruby-is-an-acceptable-lisp But oddly, I can'...

RSpec test of Treetop parser output doesn't match when it should.

I have this spec: it 'can parse armies with only section headers' do list = <<-LIST :Core :Special :Omgg :Moarheaders LIST expected_output = "## Core\n## Special\n## Omgg\n## Moarheaders\n" parsed = @parser.parse(list) parsed.should_not be_nil parsed.transform.should be expected_output end Which produces this outpu...

why use include module when class_eval by itself would suffice

In the following code include module is used. The way I see it if include module is removed then also an instance method would be created. Then why user include module ? http://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations.rb#L1416 include Module.new { class_eval <<-RUBY, __FILE__, __LINE__ ...

Ruby monkey patching pitfalls

Hi all, I'm looking for examples of why it's not a good idea to extend base classes in ruby. I need to show some people why it's a weapon to be wielded carefully. Any horror stories you can share? ...

youtube video upload with uploadify and paperclip custom processor ruby on rails ???

hi all I have a file uploader that currently uploads images / pdf with a nice progress bar using uploadify and saves to S3 using paperclip. I want to upload videos the same way but instead of to s3, i want to save to youtube. Is there a processor or something that i can use to save to youtube ? Would i be able to see the progress via...