ruby

Rails 3 and FCGI?

I want to make an app for a friend but he has shared hosting and the only option is fcgi and I can't find any documentation on how to do it. Is there anyways to run rails 3 on FCGI? ...

How do make your Ruby scripts robust with proper exception handling

I'm not asking about how to use the begin..rescue statement in Ruby. Rather, I'm asking how do you figure out what's worth worrying about. I know some hardcore people probably go through the documentation/code to find every single possible error, and have code that handles all cases gracefully. But that might be going too far if you're n...

Porting shell scripts to ruby erb templates, suggestions and advice ?

I am using Puppet for automating configuration management across hosts. It can use erb templates to set up configuration files of various services like apache, postfix etc. across different hosts Till now we were using shell scripts full of sed, awk, grep filters and such, and now I need to port that code to ruby erb templates. Let's...

Ruby: Forcing an Integer (Fixnum/Bignum) over Boolean

I have an integer that is initially 0 and, after calculations, often ends up between 0 - 99. The problem is that since early on in the game, it calculates out to 0 or 1 often, it gets assigned as a TrueClass or FalseClass instead of a numerical value, which messes up a future x > 0 comparison. Is there a built-in Ruby way to force the va...

comparision of date in ruby

how to compare particular date with today to know whether that paricular date is greater than today Thanks Harish. ...

how to validate a date

how to validate a given date ...

What are the pros and cons of rspec mocking versus other mocking frameworks?

I have seen a lot of outdated podcasts that mention mocha as a gem I would want to install because it does mocking better then rspec. I have a feeling that the rspec developers have caught on to this and have improved their mocking since then. However, in the default spec_helper.rb file I see some commented out code stubs for three mocki...

how can i get plurality of noun?

in ruby on rails,this is plural and singular functions added to ruby String class. how can i implements plural and singular functions in java? such as "book" plural() => "books" "books" singular => "book" ...

erb <% expression -%> in aspx pages

Do asp.net aspx views have tags that that work similar to the Ruby erb <% -%> ? I don't like all these line breaks in my asp.net mvc generated html. As for the other view engines (nhaml, spark, razor) I don't want to use them yet. Quick example of the difference between <% %> and <% -%> in erb: 1. <% %> <% 3.times do %> Ho!<br /> <% e...

how to make "gem install rmagick" work?

I wanted to install rmagick on Win7 but it can't install: Is there any way to make it work? C:\>gem list -r rmagick *** REMOTE GEMS *** rmagick (2.13.1) rmagick4j (0.3.7, 0.3.4 java) C:\>gem install rmagick Building native extensions. This could take a while... ERROR: Error installing rmagick: ERROR: Failed to build gem na...

Why Ruby has so many redundancies?

I love Ruby, for past couple of years it is my language of choice. But even since I started learning it, I was repelled with the fact that so often there are several ways to do the same (or equivalent) thing. I'll give couple of examples: methods often have aliases, so you always have to bother to choose the most adequate, popular or ...

Should I learn Ruby 1.8 or 1.9?

Hi, I've started to learn Ruby recently, and was wondering about which version to learn. I've got Matz's Ruby book so I have some idea of the differences, and by default I'd go for 1.9 because of the performance, working with characters, and just because there's little point learning something which will soon be outdated! However, I've...

Single quoted Ruby strings -- inconsistent escaping

Why do the following strings give me the same output in the Ruby interpreter? 'f:\new' 'f:\\new' Both strings result in: "f:\\new". I was expecting the second string to display "f:\\\\new" (if not that, then the first one should have shown "f:\new") ...

GWT and Ruby on Rails

Hello. We have RoR application and we are planning to make js interface(extjs or closure) in new version. Is it possible to use GWT with RoR? ...

Does rails have an API to check and see if times or dates exist?

Supposing a guy doesn't want users to include months or days or anything that remotely sounds like a time in his text area form. Could he use something besides regex to validate that? Is there a built-in API for that? I do use the Chronic gem somewhere else, but if I used it for this purpose, it would probably be out-of-the-box. Here's ...

Net::HTTP.start works with 127.0.0.1 but not with 'localhost'. Why?

>> Net::HTTP.start("127.0.0.1", 3000) { |http| http.get('/') } => #<Net::HTTPFound 302 Found readbody=true> >> Net::HTTP.start("localhost", 3000) { |http| http.get('/') } Errno::ECONNREFUSED: Connection refused - connect(2) Localhost is registered in /etc/hosts as follows: 127.0.0.1 localhost Telnet to both address works. ...

how to create a flat file in ruby

how can I create a flat file in ruby? Flat file is there each letter is placed at a specific column number in the file. So for example if I am reading some values from the DB: Name Class ------------------- one A two English three Math four Science and I want to make a flat file out of it wh...

Word to PDF conversion in Ruby/Rails?

Is there a gem or library to convert word document to pdf files in ruby on rails? ...

inserting commas to separate large number?

HI Is there a way i can add commas to a number like so: num= 1234567 then becomes num = 1,234,567 I would like to make this call in my helper i.e module thanks ...

How can I capture terminal arrow keys in ruby?

How can I capture arrow keys in a terminal without the user having to press "enter" after the arrow key? ...