TOP

Ruby: For loop

Could it be any simpler? This is FOR-ing through a collection, array, hash, zoo, snorkel, what have you.

<% for book in books %>
     <%= book %>
<% end %>
TOP

Ruby: Embedded Ruby (ERb)

Time.now is a ruby function to display the current time. The <%= signifies this is a value being output from ruby.

<%= Time.now %>

This uses the <% (no equals sign) which doesn't output anything on the ruby lines itself, unless you tell it to in the middle of the structure.

<% 5.times do %>
I will not con Kate and Nate in class
<% end %>

The minus sign with the ending tag gets rid of unsightly line breaks and takes 10 years off your code. Free trial today!

<%= Time.now -%>
TOP

RubyNoob: The Genesis

Today I am starting to learn Ruby, and that so I can next learn Ruby on Rails. I have flirted with the RoR language, been a long-time fan, but today I become a first-time caller. I am tired of being on the outside looking into the red-tinted party in the hizouse. It is time for me to take up the banner of gemmed goodness.

This is the start of something new. RubyNoob will be my attempt to document my journey from Ruby Noob to somewhere past the gates of proficiency, and perhaps into expertise one day in the distant future. Join me won’t you?

I will be posting RubyNoob posts with all my notes and what I learned that day in Ruby. It may not be every day, as I may not have the time to focus on Ruby much, depending on deadlines and family stuff. Let me know what you think of what will be repeated struggle and incredulousity as I learn. If you are a Ruby guru, by all means, let me have it, tell me what I am doing wrong or what it is I need to do. I’m all ears for the best advice. Thanks, and I hope you enjoy this jaunt into the gun fight with a letter opener. Maybe you will learn along with me, and be able to write Ruby and/or Rails at the end of this.

TOP

Ruby on Rails: Rake commands list

For a list of rake commands, fire up the command line and type:

rake -t