ruby

Any scrubyt command that clicks a link returns a 403 Forbidden Error

I'm trying to use Scrubyt to navigate around a website, but whenever I use it to click any links it gives me 403 Forbidden errors. The website doesn't require logins or anything so I don't understand this. Might it need some kind of session variable, or the right UserAgent string. Any idea how I might fix this? ...

Hashes of Hashes Idiom in Ruby?

Creating hashes of hashes in Ruby allows for convenient two (or more) dimensional lookups. However, when inserting one must always check if the first index already exists in the hash. For example: h = Hash.new h['x'] = Hash.new if not h.key?('x') h['x']['y'] = value_to_insert It would be preferable to do the following where the new H...

Scrubyt gives 404 Error when clicking link using _details method

This might be a similar problem to my earlier two questions - see here and here but I'm trying to use the _detail command to automatically click the link so I can scrape the details page for each individual event. The code I'm using is: require 'rubygems' require 'scrubyt' nuffield_data = Scrubyt::Extractor.define do fetch 'http://w...

Library Error for Ruby/QT

When trying to create a Ruby Qt application I get this error. /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation fault ruby 1.8.6 (2008-03-03) [x86_64-linux] I am using: require 'Qt' And am running the 64bit version of Novell OpenSUSE 11 with KDE4 installed. ...

is it time to try merb?

With Merb 1.0 rapidly approaching, I would like to know what Merb/Rails users recommend? Is it time to try Merb? What was downside for you when you switched to Merb from Rails? ...

Date class different in Ruby stdlib and Rails stdlib

I want to use the Date::ABBR_MONTHS constant in my rails application. I see the Ruby stdlib documentation at http://www.ruby-doc.org/stdlib/ which does not seem to have this constant. However, this constant is there at http://stdlib.rubyonrails.org/ What is the difference between these two libraries? This constant is working on my uni...

Ruby - How can I find out on which system my program is running?

I want my Ruby program to do different things on a Mac than on a Windows Pc. How can I find out on which system my program is running? ...

How do I convert a character code back to a character?

How to I get the Fixnum returned by the following: "abc"[2] Back into a character? ...

merb_auth_password_slice does not maintain the session

Having integrated merb_auth_password_slice as per the README, I can successfully login as redirect_after_login is being triggered, although session.authenticated? returns false. Just trying the basic auth strategy for now (password form), can't seem to get it working, any ideas? My init file: require 'dm-validations' dependencies "me...

What is the best way to validate a terminal command has run successfully in Rails?

I'm writing a quick Rails app and was wondering how I can validate the success an exec'd command. The two commands I'm running are and SVN update, and a cp from one directory to another. ...

Getting 256 colors out of ruby-ncurses

I've got 256 colors working great in my terminal (test scripts here), but it stops working when I use ncurses (via Ruby-ncurses). Printing the escape sequences given on that page works fine, but when I initialize ncurses 'puts' stops working and I can't output the colors with any of the various ncurses color changing/string output functi...

acts_as_tree does not destroy the model's children

I have this Task model: class Task < ActiveRecord::Base acts_as_tree :order => 'sort_order' end And I have this test class TaskTest < Test::Unit::TestCase def setup @root = create_root end def test_destroying_a_task_should_destroy_all_of_its_descendants d1 = create_task(:parent_id => @root.id, :sort_order => 2) d...

Stick with PHP or learn Ruby (on rails)

Hi, I am a CS student and I wanted to get some more experienced folks' opinion on the following: I have a strong background in the curly bracket languages, particularly C and Java, and have been working with php for about a year now and again. I am also currently interning at a PHP shop. My goal is to hopefully get a job in web develop...

Ruby on Rails Editor for Windows

I love to use Textmate on my Mac at home but have a hard finding somehing to use at work (windows). What is the best editor to use for Ruby on Rails on windows that get you the closest look and feel to Textmate? ...

How do I restore a windows size and position in a wxRuby app?

Does anyone know of any sample code for restoring a window's position and size in wxRuby? ...

Recursive Rails Nested Resources

I have a Rails application for project management where there are Project and Task models. A project can have many tasks, but a task can also have many tasks, ad infinitum. Using nested resources, we can have /projects/1/tasks, /projects/1/tasks/new, /projects/1/tasks/3/edit etc. However, how do you represent the recursive nature of ta...

How to get a single character in ruby without pressing enter

How can I get a single keyboard character from the terminal with ruby without pressing enter? I tried Curses::getch, but that didn't really work for me. ...

How to find where a ruby method is defined (at runtime)?

We recently had a problem where, after a series of commits had occurred, a backend process failed to run. Now, we were good little boys and girls and ran rake test after every check-in but due to some oddities in Rails' library loading, it only occurred when you ran it directly from mongrel in production mode. Tracked the bug down and i...

Ruby and duck typing: design by contract impossible?

Method signature in Java: public List<String> getFilesIn(List<File> directories) similar one in ruby def get_files_in(directories) In the case of Java, the type system gives me information about what the method expects and delivers. In Ruby's case, I have no clue what I'm supposed to pass in, or what I'll expect to receive. In Ja...

Object database for Ruby on Rails

Is there drop-in replacement for ActiveRecord that uses some sort of Object Store? I am thinking something like Erlang's MNesia would be ideal. Update I've been investigating CouchDB and I think this is the option I am going to go with. It's a toss-up between using CouchRest and ActiveCouch. CouchRest is pretty mature, and is used in...