Skip to content

Instantly share code, notes, and snippets.

@KamaKAzii
Created June 25, 2010 02:00
Show Gist options
  • Save KamaKAzii/452283 to your computer and use it in GitHub Desktop.
Save KamaKAzii/452283 to your computer and use it in GitHub Desktop.
<%= date_today = Date.today %><br />
<% i = date_today %>
<% while i <= date_today + 6 %>
<%= i.strftime("%A") %><br />
<% i = i + 1 %>
<% end %>
Copy link

ghost commented Jun 25, 2010

Change:
<%= date_today = Date.today %>

To:
<%= Date.today %>>br />

And:
<% while i <= date_today + 6 %>
<%= i.strftime("%A") %>

<% i = i + 1 %>
<% end %>
With:
<% while i <= Date.today + 6 %>
<%= i.strftime("%A") %>

<% i++ %>
<% end %>

Copy link

ghost commented Jun 25, 2010

Oh wait I see what you're doing. That won't work.

There's a better ruby control structure that you can use. Need to find it.

Copy link

ghost commented Jun 25, 2010

This will do it:
def get_days_of_week
@days_of_week = Array.new

  Date.today.upto(Date.today + 6) do |day|
      @days_of_week << day
  end

  @days_of_week
end

Put that in your helper or controller and call it in the appropriate action. Then just loop through the array of dates in your view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment