ruby

delayed_job talking to acts_as_ferret via drb server results in a closed stream error

I'm using delayed_job to process some files and then create some activerecord objects with the results. The activerecord objects are being indexed with acts_as_ferret which is running as a drb server. When delayed_job processes the job, everything goes fine until it reaches the point when active record tries to talk to ferret via the dr...

ies4linux with selenium and rspec

I use selenium, usually with firefox, to test my rails apps and it's all fine. I want to run my tests in IE6 as well. I'm in ubuntu, using the ruby selenium-client gem. For IE6 i use ies4linux, this is an executable which is at /home/max/.ies4linux/bin/ie6 I'm editing my selenium conf to try to get it to use the above, but can't get ...

extending email confirmation to Authlogic

I recently implemented Authlogic to my project for authentication. I followed http://railscasts.com/episodes/160-authlogic and had it up and running. Wanting to add email confirmation, I found this and followed it: http://github.com/matthooks/authlogic-activation-tutorial Now, when I try to sign up I get a method missing 'login=' for Us...

raise MysqlError; raise Mysql::Error both work, how did this happen?

Greetings, I was working on mysql exceptions and I came across this interesting issue, in which a raised exception is responding to two different exception names. How did this happen? -daniel #!/usr/bin/env ruby require 'rubygems' require 'mysql' require 'yaml' require 'pp' $config = YAML.load_file 'database.yml' class ExceptionPr...

How to handle POSTed XML via Sinatra Ruby app

I'm planning on using Sinatra for a new tiny webservice (WS) that I need to put together for a client. The WS will only have two methods, one accessed via GET and one via POST. For the POST method, the client will send an XML packet to the sinatra WS which will parse the data and issue either a 200 OK HTTP response or a 40x error code....

'accept_position' signal not getting called in Ruby/Gtk2

I'm creating a application with panes in Ruby/Gtk. When the panes are resized, I need to do some stuff. But I cannot figure out which signal to use. I think it is 'accept_position' - but it don't seem to work. This is a sample app that illustrates my problem... #!/usr/bin/env ruby require 'gtk2' window = Gtk::Window.new(Gtk::Window::T...

Consequences of implementing to_int and to_str in Ruby

I have a class which exposes a string value and an int value (a command output and exit code respectively). In addition to exposing them through to_s and to_i, I'm also using to_str and to_int, like so: class Status def to_s @output end alias :to_str :to_s def to_i @status.exitstatus end alias :to_int :to_i end My...

how to make a spiral galaxy image based on data points?

I'm trying to plot points from a very large array into an image using Ruby. Such that the array items are represented by a point or dot of the appropriate colour, and the dots together form the shape. Since the dots are from the array they are not random in colour or location to each other, so I'm confused how to begin. I want to even...

ruby on rails on click events

I am so sorry if this question seems too easy but I can't seem to find it anywhere. I am creating a ruby in steel project. I have created a html.erb and rb file in a vs project (ruby on rails). My problem is the following: In my html1.erb file I have created a text box and button: <p> <input erb:blockvar="erb:f" erb:method="erb::myName...

Installing Hpricot on Ruby 1.9.1 on Windows

I am trying to install hpricot using the command: >gem install hpricot -v 0.8.2 Building native extensions. This could take a while... ERROR: Error installing hpricot: ERROR: Failed to build gem native extension. C:/Ruby19/bin/ruby.exe extconf.rb checking for stdio.h... * extconf.rb failed * Could not create Makefile due to some ...

Ruby gems repository

I'm trying to set a gem repository on one of our local servers. Here are the steps I'm running, that I've followed from several guides. 1) I create the BASEDIR folder /var/www/html/gems 2) sudo cp -r /usr/lib/ruby/gems/1.8/gems/someGem /var/www/html/gems 3) sudo gem generate_index -d /var/www/html/gems However, when I run this, I get...

Need to know how hash key are handled in ruby

I am working on ruby rails project. I am using Rails 2.3.4 and ruby 1.8.7 . I have a model called User. I have following code in initializer $h = {User => 'I am user' } In the controller I have following code $h[User] First time when I do h[User] I get the right result. However if I refresh the page then I get nil value. I thi...

Is Rails hard to understand for a PHP developer?

i know nothing about ruby but a lot about php. when you code in ror...do you actually understand what is going on under the surface if you are a beginner? and do you HAVE TO understand it or is it good enough just to know enough to build something fast? Looking for experiences from people who have made the transition. ...

What are the stages a Rubyist progresses through from absolute beginner to "employable"?

I am looking for a delineation of describable stages that an aspiring Ruby programmer will have to confront, explore, and master before being considered as a professional or employable. Basically, I've been fiddling with Ruby since late 2006 and still feel lost. It's completely hobby at this point so I haven't dedicated myself to it but...

Image/ByteArray to SVG conversion?

I am wondering if it is possible to get a url to some image on google, say a square (jpg/png/gif), and process it into an SVG. Is this possible? Right now I'm getting ByteArray data in Actionscript by making a URLRequest('image/on/google'), with dataFormat="binary". I don't think Actionscript could handle/do it, but maybe it could. I...

Ruby: OOP & two-dim array question

I need to create a two-dimensional array Class. I've done a work, but discovered that my class simply has an inner two-dim array, and to access the elements I have to write a redundant word 'table': class Table attr_accessor :table def initialize(w,h) @table = Array.new(h) h.times do @table << Array.new(w) end end x = Ta...

Ruby: two dimensional array

I wonder if there's a possibility to create a two dimensional array and to quickly access any horizontal or vertical sub array in it? Ok, I believe we can access a horizontal sub array in the following case: x = Array.new(10) 10.times do x << Array.new(20) x[6][3..8] = 'something' But as far as I understand, we cannot access like thi...

Ruby MySQL log all statements to stdout/console

How can I log all executed SQL statements to the conosle/stdout when using Ruby MySQL? Like the log/development.log output from rails. ...

Active Record with Delegate and conditions

Hi, Is it possible to use delegate in your Active Record model and use conditions like :if on it? class User < ActiveRecord::Base delegate :company, :to => :master, :if => :has_master? belongs_to :master, :class_name => "User" def has_master? master.present? end end Thnx! ...

Array to nested hash

I have array of objects. I want to write method wich i will use such as this: group(array, :category, :month, year) and will return me a Hash such as this: { 'some category => { '2009' => { '01' => [objects], '02 => [objects2]code } } } This should work simmilar to group_by, but I haven o idea to do that. I ...