Sha256: 566b75d3c196cddcd326fd734267bb0cc219062d48f7c98a9d4c48663733a31f

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

# encoding: utf-8

module WorldDbAdmin

module RoutesHelper

  ################################
  ## routes for export / download (dl)

  def csv_countries_path
    # dl_countries_path( format: 'csv' )
    '/api/v1/countries.csv'
  end
  
  def table_countries_path
    # dl_countries_path( format: 'html' )
    '/api/v1/countries.html'
  end
  
  def csv_cities_path
    # dl_cities_path( format: 'csv' )
    '/api/v1/cities.csv'
  end

  def table_cities_path
    # dl_cities_path( format: 'html' )
    '/api/v1/cities.html'
  end
  
  def csv_countries_by_tag_path( tag )
    ## NB: tag needs slug NOT key (key may contain spaces)
    ## dl_countries_by_tag_worker_path( tag.slug, format: 'csv')
    "/api/v1/tag/#{tag.slug}.csv"
  end
  
  def table_countries_by_tag_path( tag )
    ## NB: tag needs slug NOT key (key may contain spaces)
    ## dl_countries_by_tag_worker_path( tag.slug, format: 'html')
    "/api/v1/tag/#{tag.slug}.html"
  end
  

  ##############################
  ## routes for shortcuts
  
  def short_country_path( country, opts={} )
    short_country_worker_path( country.key, opts )
  end

  def short_region_path( region )
    short_region_worker_path( region.country.key, region.key )
  end

  def short_city_path( city )
    short_city_worker_path( city.key )
  end
  
  def short_tag_path( tag, opts={} )
    ## NB: tag needs slug NOT key (key may contain spaces)
    short_tag_worker_path( tag.slug, opts )
  end
  
end # module RoutesHelper

end  # module WorldDbAdmin

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
worlddb-admin-0.1.1 app/helpers/world_db_admin/routes_helper.rb
worlddb-admin-0.1.0 app/helpers/world_db_admin/routes_helper.rb