ruby

XML => HTML with Hpricot and Rails

I've never worked with web services and rails, and obviously this is something I need to learn. I've chosen to use hpricot because it looks great. Anyway, _why's been nice enough to provide the following example on the hpricot website: #!ruby require 'hpricot' require 'open-uri' # load the RedHanded home page doc = Hpricot(open("ht...

Ruby - Convert Integer to String

In Ruby, trying to print out the individual elements of a String is giving me trouble. Instead of seeing each character, I'm seeing their ASCII values instead: >> a = "0123" => "0123" >> a[0] => 48 I've looked online but can't find any way to get the original "0" back out of it. I'm a little new to Ruby to I know it has to be somethi...

Ruby - Exit Message

Since I got a quick response on the last Ruby question I asked, I have another one that's been bothering me. Is there a one line function call that quits the program and displays a message? I know in Perl its as simple as this: die("Message goes here") Essentially I'm just tired of typing this: puts "Message goes here" exit ...

Trackback/Pingback libraries for Python/Ruby?

I'm considering writing my own blog but I have had some issues deciding for an appropriate software. From my survey so far I have concluded that the easiest, most feature-rich, free software is Wordpress. However, I would very much like to use several components written in either Python or Ruby, e.g. either Pygments or CodeRay as a sourc...

Ruby podcasts?

Can anyone recommend any podcasts on Ruby or that at least cover Ruby from time to time? I have only found rubiverse.com so far. I'm not interested in Rails, though. ...

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 good? What hidden...

How to profile a rails controller action

What is the best way to profile a controller action in Ruby on Rails. Currently I am using the brute-force method of throwing in "puts Time.now" calls between what I think will be a bottleneck. But that feels really, really dirty. There has got to be a better way. ...

How can I program defensively in Ruby?

Here's a perfect example of the problem: Classifier gem breaks Rails. ** Original question: ** One thing that concerns me as a security professional is that Ruby doesn't have a parallel of Java's package-privacy. That is, this isn't valid Ruby: public module Foo public module Bar # factory method for new Bar implementations ...

Getting Started with Ruby Development

What are some good online tutorials/quick starts/screencasts to get up to speed on Ruby development? I recently read Brad Wilson's Ruby article in the Sep/Oct 2008 issue of CoDe magazine and would like to continue down the Ruby/IronRuby path. (My background is mainly C# and .NET.) ...

How to program user preferences

I'm using Ruby on Rails for an internal site. Different users of the site have access to a wide variety of data and highly disparate perspectives of the data. Within those different classes of users, there needs to be levels of access. Within the levels of access I need to be able to add features from other classes of users. In the rele...

How would you test observers with rSpec in a Ruby on Rails application?

Suppose you have an ActiveRecord::Observer in one of your Ruby on Rails applications - how do you test this observer with rSpec? ...

Accessing Sharepoint from outside the WebUI

Is it possible to access the database backend of a sharepoint server? My company uses Sharepoint to store data and pictures of various assets. Ideally I would be able to access the data and display it in my application to allow users both methods of access. Before I go talk to the IT department I would like to find out if this is even p...

Is it possible to call Javascript's onsubmit event programatically on a form?

In Ruby on Rails, I'm attempting to update the innerHTML of a div tag using the form_remote_tag helper. This update happens whenever an associated select tag receives an onchange event. The problem is, <select onchange="this.form.submit();">; doesn't work. Nor does document.forms[0].submit(). The only way to get the onsubmit code gen...

Looking for examples of "real" uses of continuations

I'm trying to grasp the concept of continuations and I found several small teaching examples like this one from the Wikipedia article: (define the-continuation #f) (define (test) (let ((i 0)) ; call/cc calls its first function argument, passing ; a continuation variable representing this point in ; the program as the arg...

How do I create a SHA1 hash in ruby?

SHA Hash functions ...

How do I generate a random 10 digit number in ruby?

Additionally, how can I format it as a string padded with zeros? ...

Is there anyway to run ruby on rails applications on a windows box?

I'm looking to run Redmine, a Ruby on Rails app, on a vps windows box. The only thing I can really think of is running a virtual linux machine and hosting it from there. If that is my only option, am I going to run into problems running a virtual machine inside of a virtual machine? Also, this will be an internal app, so performance i...

RoR on Windows with Mongrel

Where is the best tutorial for getting RoR working on a windows box with Mongrel? I'm a complete novice at server management, so the more detailed the better! ...

Ruby "is" equivalent

Is there a Ruby equivalent for Python's "is"? It tests whether two objects are identical (i.e. have the same memory location). ...

How do I close a popup window, and open the next page in the main window in ROR?

I have a popup window containing a form which gathers data for a report. When I click submit in that window, I want it to close the popup, and open the report in the original window that called the popup. I think I can open the report in the correct window by using { :target => } in the form_tag, but I don't know how to determine ...