PHP to Ruby documentation
Thursday, April 24th, 2008This would’ve been so useful to me when I switched from PHP to Ruby a couple of years ago: the PHP documentation with the Ruby equivalent described for each function.
Found via RubyFlow.
This would’ve been so useful to me when I switched from PHP to Ruby a couple of years ago: the PHP documentation with the Ruby equivalent described for each function.
Found via RubyFlow.
Via Labnotes, we get to 99 bottles of beer in LOLCode. Awesome.
Not quite but Derek Sivers, an early proponent of switching to Rails for large-scale websites, has written a post on his O’Reilly blog about why he just gave up on 2 years’ work in Rails on his CD Baby project to switch back to PHP.
It’s a very sensible article looking at the fact that Rails isn’t always the answer, much as it may pain us to admit, and that when PHP (or any other language) would actually be easier to use, we just should.
That said, I haven’t been tempted back to PHP for anything just yet ![]()
Found via Ruby Inside, Chris Wanstrath has posted a great round-up of a developer’s options for session management within Rails.
Stefan Kaes’ solution looks like the one I’m gonna go for in the near future.
Something I check on the status of now and then is the ability to have a nice upload progress bar for uploads via the browser. Sean Treadway’s initial example looked great but required special server setup.
Support was added to Mongrel recently, but I never got around to properly investigating as there was no documentation of it, which didn’t help. A random check of the Mongrel site has just revealed they’ve finally added some instructions for upload progress on Mongrel.
I haven’t tried it yet (it’s late, must sleep), but at least there’s a base to work from now.
Another area I was having trouble with in Rails and found a simple plugin solution - switching layouts depending on whether you’re logged in and which theme you’ve chosen if you are.
Matt McCray comes to the rescue with his Rails Theme Support Plugin. It allows you to have multiple themes in their own sub-directories and only having copies of templates that actually differe from the application default - if there’s no theme-specific file it’ll just use the default one.
It also has Liquid templating support, though that’s not something I’m using at the moment. Might come in handy in the future though.
Another idea for a text editor/IDE feature along the lines of my previous suggestion on keeping track of things when programming: where you’ve got files from two or more different projects open at once (happens a lot for me as clients phone in asking for quick changes), why not colour-code the file tabs based on the project they’re in?
With a colour-blind brother I’m aware that colour-coding can be awkward, so perhaps some other visual aid should be added too, such as a simple number/abbreviation/symbol in front of the file name to further differentiate. Here’s an idea with the colours based on RadRails (sorry, for a quick idea in a blog post you don’t get the symbols too):

Assign each project a colour and symbol as you create it and in theory at least you can then more easily tell which of the two tabs labelled’application_controller.rb’ it is you want to click on. It would certainly be easier than either clicking on every file tab with the same name until you get the right one, or hovering slowly over each to reveal the full path to the file and figure it out from there.
Just finished the coding on my first (work) Rails project yesterday. We’re still waiting for the finished logo and content from the client though, so I’ll wait for that before posting a link as I doubt people will be too impressed with pages labelled things like ‘Blibble’.
I just got around to looking into creating RSS feeds for the news section of the CMS I’m building in Rails, so dug out my still-new Rails Recipes book and was pleasantly surprised to see how easy it was. Obviously, an RSS feed is just XML which is simple to churn out, but Rails’ XML Builder does it all in code and does it well.
The only bit I had to look up was how to get content:encoded and CDATA tags and I now have a basically-working RSS feed with this relatively short chunk of code in the .rxml view template:
xml.instruct!
xml.comment! “generator=\”infinisys/1.0\”"
xml.rss “version” => “2.0″, “xmlns:content” => “http://purl.org/rss/1.0/modules/content”, “xmlns:dc” => “http://purl.org/dc/elements/1.1/” do
xml.channel do
xml.title @site.title
xml.link url_for(:only_path => false,
:controller => ‘news’,
:action => ‘list’
)
xml.pubDate CGI.rfc1123_date(@news.first.created_at)
xml.description h(@site.description)
@news.each do |post|
xml.item do
xml.title post.title
xml.link url_for(:only_path => false,
:controller => ‘news’,
:action => ’show’,
:id => post
)
xml.description do
xml.cdata!(post.content)
end
xml.tag!(”content:encoded”) do
xml.cdata!(post.content)
end
xml.pubDate CGI.rfc1123_date(post.created_at)
xml.guid url_for(:only_path => false,
:controller => ‘news’,
:action => ’show’,
:id => post
)
xml.author h(post.user.firstname + ‘ ‘ + post.user.lastname)
end
end
end
end
TinyMCE doesn’t like pre-formatted text it seems and I can’t really be bothered faffing around, so I’m afraid it’ll all have to be in one ‘column’ for now
Nifty, non?
Sometimes this Rails lark just seems too easy, though luckily I’ve still managed to set myself a few tricky bits with this CMS so I’m not getting complacent (or feeling too redundant) just yet.
… is that it’s only relatively recently become popular so it can be hard finding advice on problems when programming. I’ve come across a couple of issues so far where I’ve posted on forums and it’s taken a day or two before you get any kind of response and a couple of times there just plain hasn’t been a response.
I think Ruby developers seem to gravitate more towards mailing lists however, so I may have to try using one of them instead.
I’m currently having trouble with the following issue. If you know of a solution, PLEASE let me know. Otherwise, if I ever find a solution I’ll try to post here for others’ reference.