Should I use Google Web Toolkit for my new webapp?

I would like to create a database backed interactive AJAX webapp which has a custom (specific kind of events, editing) calendaring system. This would involve quite a lot of JavaScript and AJAX, and I thought about Google Web Toolkit for the interface and Ruby on Rails for server side. Is Google Web Toolkit reliable and […]

How to make two thor tasks share options?

With Thor one can use method_option to set the options for a particular task. To set the options for all tasks in a class one can use class_option. But what about the case where one wants some tasks of a class, but not all, to share options? In the following task1 and task2 shares options […]

write to database with tweetstream daemon

I am trying to write all tweets that matches a keyword to my database. I have set up the following in tracker.rb: require ‘rubygems’ require ‘tweetstream’‘Bill Gates’,’money’,’Twitter Tracker’).track(‘ladygaga’) do |status| => status.text) end But nothing happens. What am I doing wrong here? Thanks in advance Update: I put everything in a .rake file […]

Using Open-URI to fetch XML and the best practice in case of problems with a remote url not returning/timing out?

Current code works as long as there is no remote error: def get_name_from_remote_url cstr = “” getresult = open(cstr, “UserAgent” => “Ruby-OpenURI”).read doc = Nokogiri::XML(getresult) my_data = doc.xpath(“/session/name”).text # => ‘Fred’ or ‘Sam’ etc return my_data end But, what if the remote URL times out or returns nothing? How I detect that and return nil, […]

Some sort of Ruby “Interrupt”

So here’s what I’m doing — I have a ruby script that prints out information every minute. I’ve also set up a proc for a trap so that when the user hits ctrl-c, the process aborts. The code looks something like this: switch = true Signal.trap(“SIGINT”) do switch = false end lastTime = while […]

How to get text after or before certain tags using Nokogiri

I have an HTML document, something like this: <root><template>title</template> <h level=”3″ i=”3″>Something</h> <template element=”1″><title>test</title></template> # one # two # three # four <h level=”4″ i=”5″>something1</h> some random test <template element=”1″><title>test</title></template> # first # second # third # fourth <template element=”2″><title>testing</title></template> I want to extract: # one # two # three # four # first # […]

has_many nested form with a has_one nested form within it

I am currently trying to make a form for a model, which has a dynamic number of nested models. I’m using Nested Forms (as described in RailsCasts 197). To make things even more complicated, each of my nested models has a has_one association with a third model, which I would also like to be added […]

Rails 3 – suddenly pending migrations error

I suddenly met a strange error. When i try to run rake spec i recieve: You have 2 pending migrations: 20130405105004 CreateReports 20130405113839 AddDocumentToReports I don’t know the reason for that (i run migrations in the past so i have data in the database and schema.rb). Here is rake spec –trace: ** Invoke spec (first_time) […]

Ruby Programming Techniques: simple yet not so simple object manipulation

I want to create an object, let’s say a Pie. class Pie def initialize(name, flavor) @name = name @flavor = flavor end end But a Pie can be divided in 8 pieces, a half or just a whole Pie. For the sake of argument, I would like to know how I could give each Pie […]

Rspec bundle is broken in TextMate and rvm

I’ve had a difficult time since I started using rvm. I’ve done all the rvm/textmate set up and have the latest bundles but I still can’t run Rspec test from textmate. I have the latest bundle from and it’s installed in ~/Library/Application\ Support/TextMate/Bundles/ RSpec.tmbundle RVM default is using the system ruby 1.8.6 Rspec gem […]

Ruby is the best programming language in the world - Ruby on Rails.