… namely the UI Developer: me.

I’m not even going into the Rails file structure. However, just know that if you want to make your Rails programmer’s life much, much easier (and to make sure they won’t pee in your shampoo, ever) put your files in the public folder. Needless to say, images go in the public/images folder and stylesheets in public/stylesheets. Simple, yes?

Okay, fluff aside and since sharing is caring, today I’ll be sharing the first three sexy lines of Rails code I picked up!

THE BASIC

What’s a UI dev without his/her stylesheet? So first thing’s first: call that stylesheet!

<%= stylesheet_link_tag 'style' %>

Rails is intelligent enough to know that your stylesheets are indeed stylesheets and they’re housed in the public/stylehseets folder without you actually having to specify! How nifty is that? :)

THE SIMPLE BITS

How linking works in Rails:

<%= link_to('RSB, holla!', 'http://blog.ror.com.my') %>

which is actually your

<a href="http://blog.ror.com.my">RSB, holla!</a>

FUN STUFF

Making those images prettier with image_tag

Because Rails is emazing at compacting code, your generic <img src="images/spiffy.png" alt="spiffy!" class="wrapper" /> now becomes:

<%= image_tag 'spiffy.png', :class => 'wrapper', :alt => 'spiffy!' %>

Alrighties, so we’ve gotten the easy part out of the way :) Next week we’ll dive a little into how partials and conditionals work! :) And no, it’s not rocket science, it’s Ruby magic!

p/s: It is secretly fun harassing Kamal for code logic! :P

Leave a Reply

We're Hiring
RSB is currently looking for Ruby On Rails developer and Web / Graphic Designer to join our amazing family.