Sha256: 1932146dffe322aee46f9ff81d3121a30f98bde5dc765e818f27cf71a06652f9

Contents?: true

Size: 820 Bytes

Versions: 4

Compression:

Stored size: 820 Bytes

Contents

# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  def format_date(d)
    d.strftime("%Y-%m-%d (%a)")
  end

  def format_month(d)
    d.strftime("%Y-%m")
  end

  # (str, date) or (date)
  def link_to_edit_logs(a, b=nil)
    str, date = str_and_date(a, b)

    link_to str, edit_logs_path(:year => date.year, :month => date.month)
  end

  def link_to_show_logs(a, b=nil)
    str, date = str_and_date(a, b)

    link_to str, show_logs_path(:year => date.year, :month => date.month)
  end

  def link_to_show_stats(a, b=nil)
    str, date = str_and_date(a, b)

    link_to str, show_stats_path(:year => date.year, :month => date.month)
  end

  private

  def str_and_date(a, b)
    if b 
      [a, b]
    else
      [format_month(a), a]
    end
  end


end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
moneyrail-0.1.4 app/helpers/application_helper.rb
moneyrail-0.1.2 app/helpers/application_helper.rb
moneyrail-0.1.1 app/helpers/application_helper.rb
moneyrail-0.1.0 app/helpers/application_helper.rb