Sha256: 06399b210109e7f90e2e62a14da57d65493865447fa3f333a7d1195650d1320b

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

# encoding: utf-8

module WorldDbAdmin

module PartHelper

  ###################################
  # helper for shared partials
  #
  # by convention all start w/ render_

  def render_tags( tags )
    render :partial => 'world_db_admin/shared/tags', :locals => { :tags => tags }
  end

  def render_cities( cities )
    render :partial => 'world_db_admin/shared/cities', :locals => { :cities => cities }
  end
  
  
  def render_countries( countries, opts={} )

    if opts[:order].present?
      if opts[:order] == 'key'
        countries = countries.order( 'key ASC' )
      elsif opts[:order] == 'title'
        countries = countries.order( 'title ASC' )
      elsif opts[:order] == 'code'
        countries = countries.order( 'code ASC' )
      end
    end

    render :partial => 'world_db_admin/shared/countries',
           :locals => { :countries => countries,
                        :count => opts[:count] }
  end

  def render_regions( regions, opts={} )

    if opts[:order].present?
      if opts[:order] == 'key'
        regions = regions.order( 'key ASC' )
      elsif opts[:order] == 'title'
        regions = regions.order( 'title ASC' )
      elsif opts[:order] == 'code'
        regions = regions.order( 'code ASC' )
      end
    end

    render :partial => 'world_db_admin/shared/regions',
           :locals => { :regions => regions,
                        :count => opts[:count] }
  end


end # module PartHelper

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/part_helper.rb
worlddb-admin-0.1.0 app/helpers/world_db_admin/part_helper.rb