ruby

Rails - Should I use boolean fields or relational table?

User model has three keys: is_master, is_standard, is_guest because I originally wanted to use activerecord boolean methods like is_master? or is_power?. However, if it would be better to create a UserType relationship and create my own methods like this: def master? return true if self.user_type = 1 end What's the best practice o...

Rails requires RubyGems >= 0.9.4. Please install RubyGems

Having the same problems as this post, except I don't think the solution is the same unfortunately. I'm getting this error message: Rails requires RubyGems >= 0.9.4. Please install RubyGems when I run a script/runner job in Cron, but it works perfectly fine when I run it in a terminal on the same server. The rails server also runs f...

Straddling checkboard algorithm improvement

Hello, ancient cryptography being one of my hobbies thanks to David Kahn's book The Codebreakers, I'm trying implement in Ruby classes to handle old ciphers such as the Nihilist cipher and ADFGVX. For these, one useful item is the Straddling checkboard. I have the following implementation in Ruby and would welcome any improvement. cla...

What resources are there for A/B split-testing in Rails?

Some information on A/B split-testing: http://startuplessonslearned.blogspot.com/2008/09/one-line-split-test-or-how-to-ab-all.html http://www.37signals.com/svn/posts/1525-writing-decisions-headline-tests-on-the-highrise-signup-page I could do this in a Rails app with a simple case or if statement in my views, but that gets to be a lo...

Calling Ruby class methods from C++

I'm trying to call a class method from C++. I've tried all combinations of rb_intern I could think of to make it work, but I've gotten nothing. Example class class CallTest def go (do something here) end end Trying to call in C++: rb_funcall(?, rb_intern("go"), 0); What goes in the ? space? I know if I use Qnil there, it...

How does one get the instance of a Ruby class running in the current RB file? (Embedding Ruby in C++)

I have embedded Ruby inside my C++ application. I have generated the bindings using SWIG. Basically, I run the ruby file and then Ruby takes over and calls my C++ class. Based on my previous question, I would like to get the current instance of the class that is defined in the ruby file back to the C++ class so that I may execute insta...

How do you test whether a model has a given method in Rails?

I would like to implement the method User.calculate_hashed_password. I'm trying to use the Shoulda testing library which works with Rails's built-in testing tools, so an answer related to Test::Unit would be just as good as one related to Shoulda (I think). I'm trying to figure out what I need to test and how I should test it. My initia...

How I turn an average desktop PC into server for hosting a website using Ruby on Rails?

What is the best way to turn an average desktop PC into server for hosting a website using Ruby on Rails? I am open to changing operating systems, buying parts if I need to, using whatever Database People recommend and any software. Here are the approximate details of the computer: The computer is an HP Desktop with 1.86GHz Duo Core...

Open Source ruby and rails projects

Which open source ruby or ruby on rails projects do you contribute to regularly? ...

How do you read an existing Rails project?

When you start working on an existing Rails project what are the steps that you take to understand the code? Where do you start? What do you use to get a high level view before drilling down into the controllers, models, helpers and views? Do you have any specific techniques, tricks or tools that help speed up the process? Please don...

How do you validate attachment_fu's image width and height?

I want to be able to validate the image is exactly a certain with or a certain height, or if it's square. In the validation block of the model that has_attachment, when I try to access image_size, width, or height, it always comes out as null. I also asked the question here if you want more details. ...

Asynchronous alarm signal

I'm looking for a portable interface to POSIX alarm(2) (or similar) in Ruby. That's to say, I would like to be able to set a background timer to send a signal to the current process after n seconds. I have found some good discussion from 2006 on the ruby-talk list that provides a solution using dl/import, but that's a bit of a hack (alb...

Best plugins and gems for parsing email ala Highrise

I am looking for recommendations on the best Rails plugins and gems for parsing email and inserting it into the database, similar to the way Highrise and Basecamp (among others) work. Described here http://wiki.rubyonrails.org/rails/pages/HowToReceiveEmailsWithActionMailer Are there any that people recommend, currently? ...

The "Ruby" way of doing an n-ary tree

I'm writing a Ruby script and would like to use a n-ary tree data structure. Is there a good implementation that is available as source code? Thanks. ...

Iterate over Ruby Time object with delta

Is there a way to iterate over a Time range in Ruby, and set the delta? Here is an idea of what I would like to do: for hour in (start_time..end_time, hour) hour #=> Time object set to hour end You can iterate over the Time objects, but it returns every second between the two. What I really need is a way to set the offset or delt...

Do any big companies use Rails internally?

I keep hearing about Rails being used by startups but have not heard of, say, Morgan Stanley using it. Is there a list somewhere of bigger companies that use Rails internally? ...

Are you using AWSDBProxy? Is there a performance hit when scaling out?

After a down vote, I humbly realized that my post was an enormous rant. So I've edited it and summed this down to just the question I'd really like to know. I apologize for my brash comments prior to this edit ;) It seems that the only tutorials out there talking about using Amazon's SimpleDB in a rails site are using AWSDBProxy... Per...

What is the most active public forum/message board for discussion of Rails implementation issues

I found quite an active discussion on WorkingWithRails but can't tell if this is the most active of the Rails discussion forums? Where do most people go to ask questions? ...

When does the finish event get called in shoes?

Using Shoes, I would like to have a block executed upon window destruction. I thought I could use the finish event, but in the following piece of code, "Starting" is displayed, but "Finished" is never shown. Shoes.app(:title => "Test") do flow do start do |obj| alert("Starting") end finish do |obj| ale...

environment path loading incorrectly in bash

I recently installed the Macports port of Ruby19 and it's changed my environment settings to point to opt/local in the first instance rather than usr/local where I have my standard 1.8.7 install. I've tried updating my ~/.profile by adding the usual export PATH etc. as the last line but to no avail. I have to run the .profile file each ...