small medium large xlarge



Activity 1

Experiment with the following expressions:
  • Addition: <%= 1+2 %>
  • Concatenation: <%= "cow" + "boy" %>
  • Time in one hour: <%= 1.hour.from_now %>

Hint: pay close attention to the time zone as it will be reported in Universal Coordinated Time, some times referred to as GMT.


Activity 2

A call to the following Ruby method returns a list of all the files in the current directory: @files = Dir.glob('*')

Use it to set an instance variable in a controller action, and then write the corresponding template that displays the filenames in a list on the browser. Hint: you can iterate over a collection using something like this:

<% for file in @files %> file name is: <%= file %> <% end %>

You might want to use a <ul> for the list.

Discuss (contains spoilers)

Page History
  • V6: Sam Ruby [over 4 years ago]
  • V5: Sam Ruby [over 4 years ago]
  • V4: Sam Ruby [over 4 years ago]
  • V3: Sam Ruby [over 4 years ago]
  • V2: Andrew de Andrade [about 5 years ago]
  • V1: louis_wu [about 5 years ago]