1
2
3
def caesar(text, shift)
  text.split('').collect {|letter| (letter[0] + shift).chr}.join
end

Ruby On Caesar Cipher

by Fabien Jakimowicz, August 09, 2008 11:34
Be1e3ee645d23c95ba650c21bc885927 Talk
1
2
3
class Account < ActiveRecord::Base
  has_many :websites
...

Ruby On Rails - Multiple instances ...

by Fabien Jakimowicz, August 03, 2008 12:48 Star_fullStar_fullStar_fullStar_fullStar_full

You should move a lot of lo...

Be1e3ee645d23c95ba650c21bc885927 Talk
1
2
3
class MyaccountController < ApplicationController
  before_filter :load_users, :only => [ 'account_details', 'show_email_box', 'show_mobile_box' ]
...

Ruby On How to make instance variab...

by Fabien Jakimowicz, July 31, 2008 13:33 Star_fullStar_fullStar_fullStar_full

You can use a before filter...

Be1e3ee645d23c95ba650c21bc885927 Talk
1
2
3
4
def update_foo_and_bar
  # You can also use @foo.class.transaction and @foo.bar.class.transaction if you have multiple database at the same time
  ActiveRecord::Base.transaction {@foo.update_attributes!(params[:foo]) and @foo.bar.update_attributes!(params[:bar])}
...

Ruby On Saving multiple models in o...

by Fabien Jakimowicz, July 29, 2008 22:21

there is a lot of way to cl...

Be1e3ee645d23c95ba650c21bc885927 Talk
1
2
3
4
xml = REXML::Document.new(data)

artists = xml.elements.to_a('//artist')[0..limit].collect do |artist|
...

Ruby On cleaner way to limit result...

by Fabien Jakimowicz, July 14, 2008 23:38

i'm not familiar with REXML...

Be1e3ee645d23c95ba650c21bc885927 Talk
1
['foo', 'bar', 'baz'].each_with_index {|j, i| puts "#{i} #{j}"}

Ruby On Python's enumerate in Ruby?

by Fabien Jakimowicz, July 14, 2008 23:23 Star_fullStar_fullStar_fullStar_fullStar_full
Be1e3ee645d23c95ba650c21bc885927 Talk

Ruby On collecting attributes from ...

by Fabien Jakimowicz, June 17, 2008 15:32 Star_fullStar_fullStar_full

I thought the same about ht...

Be1e3ee645d23c95ba650c21bc885927 Talk
1
2
3
4
# Rails < 2.0
Carrier.find(:all).collect {|d| [d.id, d.name]}.flatten

...

Ruby On collecting attributes from ...

by Fabien Jakimowicz, June 17, 2008 11:52 Star_fullStar_fullStar_fullStar_fullStar_full
Be1e3ee645d23c95ba650c21bc885927 Talk