Archive for April, 2008
The more I work with Ruby and Ruby on Rails, the more I begin to understand (though not necessarily agree with) a lot of the vitriol that has been aimed at PHP over the years by developers using other more rigorous languages.
A few weeks back I ran into this little speed bump while working with Ruby on Rails, where I was trying to do a multiple assignment like this
Most seasoned Rubyists will be waving their arms around and yelling “NOOOOOO!!!”
But coming from a PHP background this seemed perfectly okay to me.
Let me go off on a (relevant) tangent here and show you how the PHP code for this assignment would work
$x = $y = $z = array();
$x = 'me';
print_r($x);
print_r($y);
print_r($z);
the output from this is
me Array() Array()
Notice how the variables $y and $z remain arrays?
Now lets look at the same ruby code.

You can see that when we do an assignment of
ALL the variables point to the same array, so changing one item, changes all the other variables!
This is because arrays, hashes and certain objects are passed by reference not by value.
I say “certain” objects because the assignment
… doesn’t work the same way - as you can see above - even though the quoted string “you” is an object in Ruby.
So be careful PHPsters … this cost me a couple of hours in my project.
Hopefully you can skate around this one if you come across it.
April 29th, 2008
This one took a little bit but I finally figured it out …
@xml = render_component_as_string :controller => “quote”, :action => “xml”, :params => {:request_id => 100}
This would run the action “xml” of the controller “quote” and pass the parameter “100″ to it to do so.
Whatever would have been displayed at /quote/xml/100 is now stored in @xml
This allows you get the output from any action …. anywhere, also allowing you to pass parameters to it in the process.
Even better, this actually runs the action and its view (unlike render :action, which just renders the action view).
For more details, go to the Ruby On Rails Manual > Using components
April 17th, 2008
I have been unable to play around with mod_rails (the apache module that allows you run Rails apps in apache) and write a “mod_rails 101″ type blog post.
However, I came across this excellent mod_rails tutorial on how to get up and running.
Just thought I should share.

April 16th, 2008
After weeks of anticipation , the apache module that allows you to upload your ruby on rails application to the server and have it “just work” has just been released.
I’ve just downloaded the source code from their git repository (git rocks!!) and am trying to see if it’ll install on windows.
Update: It won’t install on windows and there are no plans to ever allow it to (damned Linux elitists!!! :P).

April 11th, 2008
I’ve been interested in moving to the new Versioning system championed by none other than Linus Torvalds … creator of Linux.
But I’m on a windows box (and I like it here) and didn’t want to deal with using cygwin to manage repositories in Git.
Cue this succinct blog post on how to run Git on windows.
enjoy.
April 4th, 2008