Posts tagged with " development"
Mobile Websites with Ruby on Rails 2.0

So seeing as I have had a bit of free time over the past day (30 minutes), in between my own job here in Dublin and helping my parents out in their bar over the holidays I've also been looking at creating a nice and minimalistic mobile site for beilabs.com. It's not up and running yet but hopefully it will be shortly.
As I won a nice new IPOD Touch last month I decided to put the mobile safari browser to some use and check to see how well rails looks on it. Apparently there is a mac application designed for exactly this purpose called iPhoney but I prefer to use the real thing.
Now there are quite a few ways that creating a mobile rails site can be accomplished however I went for the nice easy way and decided to just find out the users mime type.
The Juicy Bits
First we add a helper method to application_helper.rb
# Request from an iPhone or iPod touch? (Mobile Safari user agent)
def iphone_user_agent?
request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Mobile/.+Safari)/]
This is vital to ensure future compatibility with apple hardware. Bear in mind that this is a short term solution as there will be plenty of nice browsers on mobiles in the future such as Opera to name one.
So next in our view we can redirect them to an optimized website specifically for the iphone/itouch safari mobile browser
<div class="message">
<p>Using an iPhone? <a href="http://iphone.beilabs.com/">Use the optimized version</a>.</p>
</div>
<% end -%>end
Back to Reality
http://mobile.beilabs.com is not even up yet, it's barely a figment of my drunken imagination but it will be soon I hope. Anyhow, I'm off to watch Kill Bill, I hope that gave some people a bit of an idea about how to make a rails mobile website. Easy eh? Yeah, it always looks that way.
Globalize on Rails needs a quick patch…

Throughout my Rails journey I have come across a number of problems with various plugins. The globalize plugin is one which can completely localize an application through a database and some simple syntax. Chinese & English sites here I come…Anyhow during the install of Globalize for Rails 1.2 I came upon the following error and here is it’s solution if anyone needs it.
This has been tested on a fresh Globalize install on Debian, Rails 1.1, MySQL –version:
“mysql Ver 14.12 Distrib 5.0.32, for pc-linux-gnu (x86_64) using readline 5.2″
Error
================
** Execute globalize:create_tables rake aborted! Mysql::Error: #42000Identifier name ‘index_globalize_translations_on_table_name_and_item_id_and_language_id’ is too long: CREATE INDEX index_globalize_translations_on_table_name_and_item_id_and_language_id ON globalize_translations (table_name, item_id, language_id)
================
Cause
================
On Globalize Migration, line 32, an index to globalize_translations is created. However, this fails due to the index name being added as: add_index :globalize_translations, [ :table_name, :item_id, :language_id ]
… which in turn tries to create an index name of: index_globalize_translations_on_table_name_and_item_id_and_language_id
This is 70 characters, which exceeds the index identifier limit of 64 characters: http://dev.mysql.com/doc/refman/5.1/en/identifiers.html
================
Solution
================
One solution is to rename the index name, in: globalize/generators/globalize/templates/migration.rb (migration.rb.gz:32 && tiny_migration.rb.gz:31)
…to:
add_index :globalize_translations, [ :table_name, :item_id, :language_id ], :name => ‘glb_trns_idx’
================
If this is double dutch to you then pay no heed, it will definitely help out some poor other misfortunate person and save them some much valuable time in the future.
New RSS Feed
Just to let everyone know that I have created a nice new script which will take a huge load off of the server. Before today everytime the server received a request for the rss xml file it was automatically generated by the application, this could lead to hundreds of requests and a large load. But thanks to some spare time I now have it creating a nice and small xml file at specific intervals with a ruby cron job script (I love script/runner)
Anyhow, if all the above is just double dutch to you then just listen to this. If you read this blog, then please update your RSS feeds to http://www.beilabs.com/beilabs.xml
Wow, two blog posts in one day. I'm on a roll, usually on this blog I leave such gems for every 6 months. I'm aiming to update this blog at least once a week from now on, maybe even more. Ain't ye the lucky ones!
Rails 2.0 is now a go...

Beilabs is now updated to Ruby on Rails 2.0. First thing I'm going to do is implement the mobile.beilabs.com website. Hopefully I'll have it complete by tonight. Wish me luck.
Some new stuff going on here
So as you can see I've finally began to start making some small adjustments to this website. The small things are finally a new AJAX comment box area which stop page refreshes, also are some html tags are allowed.
There is a small summary of each blog post on the very front page and I've decided to extend it a little further so that everyone can see the latest stuff that I am doing on last.fm, del.icio.us and flickr to name a few. I'll also be working on a tag cloud as well as making the blog more AJAXy in general over the forthcoming months.
So I am working for a company called Arvato Finance as a Senior Business Analyst, and much of the stuff I do is designing internal system applications on Ruby/J2EE/Rails/PHP/VB/J2EE. It's a bit messy with all of these different frameworks at the moment but we will be merging most of the internal web applications into Ruby on Rails so that will be interesting for a time. The core business applications are of course not written in Rails, it is viewed like the plague, something the core team wishes to stay away from. MySQL it should be known, for a core application, is viewed as a dirty word where Oracle apparently reigns supreme. Hopefully my time here can change such perceptions of Open-Source code and products.
I've been developing with Ruby for the past three year and rails somewhat for the past two years now and I am still very much in love with the language as when I first saw it. It is to this effect why much of my own code written as a hobby is primarily written in Ruby. Having seen the Chinese mass produce J2EE code by throwing as many bodies at the problem I saw that for a one man team J2EE really doesn't suit me and my methods of fast prototyping and in this regards rails suits me perfectly.
Anyhow, at the moment I am an extremely busy guy, deadlines due and all that jazz. If ya like what I am doing to the site over the coming weeks lemme know and leave a comment. If of course you have any suggestions just let me know and I'll think about it further... :)
