ruby

Is the default Ruby install on Mac OSX 10.5 "good enough" for Rails development?

OSX 10.5 comes with Ruby 1.8.6 I believe, but I see a lot of tutorials that recommend installing the latest version of Ruby from source. I've done this in the past and it's caused minor issues down the road if I install something which expects Ruby to be in the default location and it's not (Phusion Passenger pref pane, for instance). ...

How do I convert a ruby hash to XML?

Here is the specific XML I ultimately need: <?xml version="1.0" encoding="UTF-8"?> <customer> <email>[email protected]</email> <first_name>Joe</first_name> <last_name>Blow</last_name> </customer> But say I have a controller (Rails) that is sending the data to a method, I'd prefer to send it as a hash, like so: :first_name => 'Joe...

What's the difference between a proc and a lambda in Ruby?

And when would you use one rather than the other? ...

Create a daemon with double-fork in Ruby

What is the proper way to create a well-behaved Unix or Linux daemon in Ruby? What is the definition of a well-behaved daemon anyway, and how would one write such a program in Ruby? ...

Dynamic Table in Model

Is it possible to make a model that uses a different table dependent on an association. ...

Screensaver to cycle through webpages?

Hi, Does anyone have any suggestions for how to create a screensaver that can cycle through some webpages? I would like to create a screensaver that displays various dashboard and statistics pages that are available in our Hudson CI server. This is a windows machine, with firefox and IE available. Extra bonus points if I can do it in...

Are there any "simple" explanations of what procs and lamdbas are in Ruby?

Are there any "simple" explanations of what procs and lamdbas are in Ruby? ...

translate python method to ruby

What would be the correct translation of the following Python method to Ruby? def uniqueCombinations(self, items, n): """ items: list of elements n: number in a group """ if n == 0: yield [] else: for i in range(len(items)-n+1): for cc in uniqueCombinations(items[i+1:],n-1): ...

how to invoke ruby script containing system command with cron job?

I have a ruby script containing system command like http://gist.github.com/235833, while I ran this script from shell, it works correctly, but when I added it to my cron job list, it doesn't work any more, the cron job is like: 10/* * * * * cd /home/hekin; /usr/bin/ruby my_script.rb any idea what's going wrong with what i've done? ...

Syncing Rails development environments on my two computers

So far I have been building my Rail app on a Mac OS X box using TextMate. It's just me, so I haven't used Git. I have just opened and closed the code in the file system, used an AppleScript to take annotated snapshots at key moments, and let Time Machine take care of the rest. I've just ordered a Windows laptop which I'll use for the s...

How to display HTML inside text area using Rails.

I know that questions about this topic exist, but i would like to know if anyone knows a solution for rails :) I'm using a text_area_tag helper, and the contents that i want to display contain HTML tags.. any idea? ...

How to turn a single-site app into a mantainable multi-site app without code changes?

It's an application that we use internally at the office that I would like to offer as a hosted service for anyone. How can I do that without making major code changes? The first thing that occurs to me is to have the app select which database to connect to based on the domain. So each instance of the app would have its own databas...

how to set up a new rails program

I've heard a lot about rails, what is it and how does it work? ...

Why is this regex not working properly?

I have this regex: ^\/\* to check and see if a file contains those two characters at the beginning. I'm iterating over many c++ source files trying to see which of them contain that. The problem is, that if a file contains this: #include <source.h> /* this is a comment */ this also matches the regex. I don't understand why, as the re...

conditional haml - if else nesting

What I want is both whats in "if" and whats in "else" to include #main-block. - if @transparency #content-inner{:style => "background: url(../../../images/illustrations/" + @transparency + ") no-repeat 88% 50%"} - else #content-inner #main-block What happens currently is, if @transparency is defined, #main-block is not neste...

How to test email sending using Rspec?

What are the best practices and tools to test email-sending using rspec with Rails? For instance, how do I test that an email has been sent or what should I test to have efficient testing and acceptable coverage. If you guys need an example, how would I go and test this: class UserMailer < ActionMailer::Base def jobdesc_has_been_re...

Faking web requests in Rails test without Fakeweb

I'm using the Handsoap gem with Httpclient gem as the driver in a Rails app. How can I prevent network calls from Handsaop/Httpclient gems in test cases? FakeWeb doesn't support Httpclient. ...

haml syntax - better way of writing this?

There must be a better way of writing this- I'm just not sure how (using staticmatic)- - if current_page.include? "0.html" - @current_index = 1 - if current_page.include? "1.html" - @current_index = 2 - if current_page.include? "2.html" - @current_index = 3 - if current_page.include? "3.html" - @current_index = 4 - if current_pa...

A simple TCP messaging protocol?

I want to send messages between Ruby processes via TCP without using ending chars that could restrict the potential message content. That rules out the naïve socket.puts/gets approach. Is there a basic TCP message implementation somewhere in the standard libs?. (I'd like to avoid Drb to keep everything simple.) ...

Ruby Based Blogging Engine

What Rack enabled blogging engines exist? I want to deploy a free blog to heroku and need more customizabilty than the free hosting of Wordpress.com or Blogerty provide. Also in another note, has anyone tried to port Wordpress to Ruby? ...