ruby

Twitter/Facebook API for Ruby.

I want to write a Ruby application through which: I can submit tweets to twitter. I can submit a post to facebook. I can manage real-time stats of tweets Is there any twitter/facebook api for Ruby? ...

Ruby Irb reacts strangely to control keys

Hi. I'm (extremely) new to Ruby, having started today. I just moved from my system's Ruby 1.8 installation to Ruby 1.9, compiled from source. In doing so, irb has taken a turn for the worse. It reacts in a most unfriendly way to the non-alphanumeric control keys: UP key prints: ^[[A DOWN key prints: ^[[B DELETE key prints: ^[[3~ ...

Breakpoints in Ruby IDE?

Hey there, I currently use TextMate for Ruby/Javascript/Actionscript development and it is amazing. But one thing I would really love to use are breakpoints so I could stop code execution and examine the state of the variables and walk through the code. Something like what Flex Builder does. Does TextMate have this capability? Or wh...

How do you access an instance variable in an Authlogic config block?

Given a user model something along the lines of: class User < ActiveRecord::Base acts_as_authentic do |config| config.validate_email_field = true end end I would like to be able to modify "true" to be specific to the user that is signing up. I would like to be able to do something like: class User < ActiveRecord::Base ac...

how to prepare for a Ruby interview in just one weekend

I'm a seasoned web developer but only have a modicum of Ruby/Rails experience. I just got an interview Monday at a Ruby shop, they do realize I don't have much Ruby experience. Besides 2 or 3 Ruby books I have lying around, what other resources might I avail myself of for a weekend crash course in Ruby. I do have a bare minimum accoun...

Rails fake deletion of a row

I'm looking for a way to faux-delete rows from a table using Rails. The rows shouldn't show up in any normal .find() search except for when I want to show recently deleted items. I'm using an Activities table right now for management of such tasks, which stores the class, id and method performed on rows recently. Is there a way to disab...

EventMachine : How to build a chat system with Rails application

I am building a chat system using EventMachine and ruby on rails. It's for learning purpose. This is how client is connecting to server. c = TCPSocket.open(ip_address, port) data = {:user_id => 2, :message => 'hello world'} c.send(data) response = c.gets c.close It works. However the problem is that I can't get the list of people who...

Decorators in Ruby (migrating from Python)

Hi. I'm spending today learning Ruby from a Python perspective. One thing I have completely failed to grapple with is an equivalent of decorators. To pare things down I'm trying to replicate a trivial Python decorator: #! /usr/bin/env python import math def document(f): def wrap(x): print "I am going to square", x ...

Complex date find and inject

I am building a financial reporting app with Ruby on Rails. In the app I have monthly financial statement objects (with 'revenue' as an attribute). For any single financial statement, I want show (1) year-to-date revenue, and (2) last-year-to-date revenue (calendar years are fine). Each object also has a Date (not Datetime) attribute c...

Given two directory names, how can I get relative name of one as if another is working dir in Ruby?

In my Rails application, I need to create a symlink between two files inside RAILS_ROOT. The names of target and symlink are given as absolute paths. However, I want to create a symlink that uses relative paths, so the application folder could easily be moved. In other words, from RAILS_ROOT/path/foo/bar and RAILS_ROOT/path/baz I want...

Rails User model has_many activities (observer) but should also be observed

I'm running into an issue with an existing ActiveRecord::Observer model that records various Activities of a User the site. Everything was working really well, until I tried to observe the User class with the same Activity model that it uses to observe other models. Consider that: class Activity < ActiveRecord::Base belongs_to :user b...

How to set the mechanize page encoding?

Hi, I'm trying to get a page with an ISO-8859-1 encoding clicking on a link, so the code is similar to this: page_result = page.link_with( :text => 'link_text' ).click So far I get the result with a wrong encoding, so I see characters like: 'T�tulo:' instead of 'Título:' I've tried several approaches, including: Stating the enco...

Rails test fixtures vs uniqueness

In Rails, fixtures records seem to be inserted & deleted in isolation for a given model. I'd like to test having many objects/rows in one transaction, eg. to check uniqueness. How to do it? ...

What are the various popularity metrics and sites for programming languages such as Ruby, Python, Java, etc?

What are the various sites that offer metrics that compare Ruby, Python, Perl, Smalltalk etc. What are their respective metrics? Do any of them control or account for the time that Rails was introduced, and/or the adoption rates for various languages? Will someone please help me close this question? Clearly it was not a successful vent...

Code and unit tests in two different laguages?

I've recently have started writing unit tests for PL/SQL code in Ruby. Are there any other language combinations where you write your code and unit tests in two completely different languages? ...

making ruby 1.9 the default ruby on ubuntu

Is there any way, on Ubuntu 9.04, to install ruby 1.8 as ruby1.8 (or get rid of it altogether) and have ruby 1.9 be the default ruby? ...

RSS feed from MySQL table using either Ruby or Rails or Gems

I have a MySQL table and I want to pick certain columns to create RSS Feed from it. How to do it using Ruby or Rails or Gems? ...

clean up strange encoding in ruby

I'm currently playing a bit with couchdb. I'm trying to migrate some blog data from redis (key value store) to couchdb (key value store). Seeing as I probably migrated this data a gazillion times from and to different blogging engines (everybody has got to have a hobby :) ), there seem to be some encoding snafus. I'm using CouchREST to a...

Code completion for Sketchup Ruby API

Hello does anyone know of a program that has support for code completion for Sketchup Ruby API. Thanx for answers Ladislav ...

Why do I need asterisk before an array?

I have no idea if this is a Hash issue or an Array issue, but I don't figure out why asterisk (*) sign is required in the third example to get a hash filled with data. Without it, it outputs an empty hash. # -*- coding: utf-8 -*- require 'pp' pp [[:first_name, 'Shane'], [:last_name, 'Harvie']] # => [[:first_name, "Shane"], [:last_name, ...