Smoke Signals

Monday, March 21, 2005

I’ve been workin on the railroad

Ok, on part v0.1.2 of my working with rails series I am going to talk about the other scattered but important parts of rails that you will need to know. Unless you are one of those people who just follows instructions and doesn’t care about the why. If so, exit stage right…

Once you get past your todo list or recipe app, you may want to create a “real” application of sorts. For me, it is a CMS. So I ventured out on this journey also wanting to learn how to solve some common scenarios in rails. During this trek I came across some things that have been a bit difficult to understand to say the least. Now I have been able to find explanations of some of these rails/ruby “idiosyncrasies” in addition to figuring them out by sheer brute force. I will be documenting them as I move along and find more:

What’s with all the <% ?

Ok, when you tear apart your scaffolding-generated views you will find some funny looking tags. A bit php, a bit classic asp or inline code for _insertYourLangHere_ . They look like this: <% something %> and <%= something_else %>. With a bit of digging I found out it is called ERB AKA Embeded Ruby. So, if you want to know more about the ERB go do some digging of your own. Now, some of you who have been paying attention may have noticed they are a bit different. Notice the = sign on the last tag. Well, it turns out it isn’t just for shits and giggles. I found that out by getting a bit pissed when my @session wasn’t spitting anything out. The equal sign means it is going to render/output something in your HTML. The tag without the = means it is just a loop or something else and does not need to output into your HTML. Wow, all those gray hairs I produced for that.

Stay tuned for more…

1 Comments:

Post a Comment

<< Home