I’m a newcommer to Ruby and Rails. I’ve just got the environment done on
my Mac OS X machine and I am eager to start to learn more!
It seems as such a great plattform for doing webapplications.
I have a specific task I would like to acomplish but being a newbie with
Rails and Ruby am not sure where to start.
What I want to do is to create a mobile site that is very goood at
detecting which device is used for accessing the web application and
then adjust the pages accroding to the devices capabilities.
Fortunately WURFL (http://wurfl.sourceforge.net/) is excellent at
identifying the various devices. For the Java world there is a tag
library (WALL - http://wurfl.sourceforge.net/java/index.php) that
implements a JSP tag library on top of WURFL - this makes it very easy
to develop web applications that behave cleverly with the different
devices out there. It handles WAP phones, XHTML browser and more.
The WURFL project has sometools and examples in Ruby
My problems is that as a newbie to both Ruby and Rails i do not know
where to start? Is there something similar to JSP TAG libs? If not, can
you ecommend better approaches?
What I would like to do is to get the same ease-of-programming as if
using the WALL JSP taglibs in a Java environmet.
Could anyone here help me plot a course for how to go about this?
java tag libraries - as you’ll know - are shortcuts to classes that
render markup. If I define e.g. a tag named myTag and initialise it in a
tld-File with it’s reference to the class my.namespace.MyTag which
renders something like
my list
then a simple reference like mytl:myTag will get the output of the
rendering class and replace my directive with the rendered markup (here
html but might as well be wml, xml et. al.), right?
IMHO (being a n00b myself) the rails equivalent to functionality like
this are helpers (and components). In helpers you’ll define methods that
render html and may be placed in your templates. Things aren’t very
different. The learning curve for tld-Development is definitly steeper
than developing helpers in rails. My approach to your problem therefore
would be:
Researching if there are any native ruby libraries that provide
functionality like wurfl
Researching what the wurfl project already provides for ruby
Rebuilding the WALL tld in rails helpers (probably quite a task): Is
WALL open source? Then you would start at the tld-File, introspecting
the Rendering-Classes that are referenced in the tld and build
equivalent helpers in rails.
As a first step you might make yourself familiar with the rails
rendering kit. Keywords are Templates, Partials, Helpers, Components