ruby

mingw32 Ruby Installer for Windows

How good is the new Ruby Installer for Windows? I asked before about why Ruby was so slow on windows and now I've seen some impressive benchmarks showing marked speed improvements with the minGW compilation used in the new installers and am curious how it has worked for people who have tried it? How many gems are broken for this versio...

Hashes vs. Multiple Params?

It is very common in Ruby to see methods that receive a hash of parameters instead of just passing the parameters to the method. My question is - when do you use parameters for your method and when do you use a parameters hash? Is it right to say that it is a good practice to use a parameter hash when the method has more than one or tw...

When do you use method aliasing?

Do you use the alias method in order to add more ways to call methods (like length and size) or is there another use for it? ...

Make XML builder insert XML from string

I have an XML view in a rails app, and need to insert in XML from another file for testing purposes. I want to say "builder, just stuff this string in blindly, because it's already xml", but I can't see to see anything in the docs that does that. ...

How to resolve deprecation warnings for OpenSSL::Cipher::Cipher#encrypt

I've just upgraded my Mac to Snow Leopard and got my Rails environment up and running. The only difference -- OSX aside -- with my previous install is that I'm now running ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0] (Snow Leopard default) rather than 1.8.6. I'm now seeing deprecation warnings relating to OpenSSL when I...

how can i authenticate users out of rails with authlogic?

in my system, users registering via rails website. i have to authenticate users from a custom application server written in ruby. error messsage: You must activate the Authlogic::Session::Base.controller with a controller object before creating objects (Authlogic::Session::Activation::NotActivatedError) ...

simple regex -- replace underscore with a space

Hey, I'm writing my first Rails app, and I'm trying to replace the underscores form an incoming id name with spaces, like this: before: test_string after: test string How can I do this? Sorry if this is a bit of a dumb question, I'm not very familiar with regular expressions... ...

Creating Ruby ActiveRecord objects with associations

I have Persons and Teams that have Addresses (polymorphic association) I need to create persons and addresses separately in code: person = Person.new address = Address.new and then link them together using something like: person.addressable.push(address) finally, do: person.save! This however gives a You have a nil obje...

ruby class extensions

I would like to write a method in ruby that takes a class with certain methods and modifies its behavior by adding methods or changing how existing methods work. I would like to do this in a way that doesn't modify the base class so basically I want a function that takes a class and returns a new modified class without harming the initia...

Migration Shorthand

Now in rails we can use t.string instead of t.column using t.string is easy.But t.column is a deprecated feature? any other advantage of using t.datatype other than easiness. Is there any way to convert all current migrations to new style easily. ...

What are some tips for debugging Ruby erb files?

Currently, when I get an error on an erb template (for use with HTTPServer/cgi) I do the following: If it's a small change, revert, save and retest. For a large change or new file, delete or comment 1/2 the code, and retest. Perform a binary search until I've deleted/found the broken code. The call stack doesn't seem to correspond t...

Ruby: Mailing List library or gem

Can anyone recommend a good gem or library for managing a mailing list with Ruby? No Rails solutions, if possible, please (I don't want to have ActionWhatever dependencies, this will most likely be done with Ramaze). I just need basic features, like management of the list itself (CRUD operations on the user list), plus being able to se...

'River of news' code sample in ruby?

Looking for a good example of a 'River of News' implementation done in Ruby. Rails, merb, sinatra or any other web framework would work. I have a couple ideas about how to implement it, but would love to see how people would do it. The implementation should load more items into the same page as soon the user reach the bottom of the doc...

What version of Ruby should I use with Rails 2.3.3?

Can I use Rails 2.3.3 with Ruby's latest version (1.9.1)? On this page, they recommend Ruby 1.8.7. ...

when to ditch active record?

I'm not new to Rails but I've not done anything quite so complicated as this so far, so I'm curious what a more experienced rails developer might share: I have a sql query which joins 4 or so tables into one output: SELECT places.id, places.name, places.email, places.website, places.blurb, external_ratings.rating, photos.data_file_name...

How can I see what the request object looks like?

Whenever I try logger.info ("REQUEST: \n " + request.to_yaml) I get this error: can't dump anonymous class Class What's the best way to see what's in the request object (in a readable way)? ...

How to break outer cycle in Ruby?

Hello. In Perl, there is an ability to break an outer cycle like this: AAA: for my $stuff (@otherstuff) { for my $foo (@bar) { last AAA if (somethingbad()); } } (syntax may be wrong), which uses a loop label to break the outer loop from inside the inner loop. Is there anything similar in Ruby? ...

How to get redirect log in Mechanize?

Hello. In ruby, if you use mechanize following 301/302 redirects like this require 'mechanize' m = WWW::Mechanize.new m.get('http://google.com') how to get the list of the pages mechanize was redirected through? (Like http://google.com => http://www.google.com => http://google.com.ua) OK, here is the code in mechanize responsible fo...

Realtime with PubSubHubBub

Hi All I'm trying to implement real time chat engine with PubSubHubBub as the core in Rails. My question is what I need to do to or read to achieve this task ? Where I'm gonna start ? What knowledge do I need to know first because I'm really really newbie in this field and like to play with it... or are they any realtime chat engine tha...

Continue education or put myself out there?

Hi, I've been programming as a hobby for a long time. I'm 23 years old and and haven't completed college. My job right now is not programming related (although it is in IT). I just started going back to college this year (a community college) and I'm finding it very difficult because the classes are extremely basic. I don't feel comfort...