Skip to content

Commit

Permalink
add places
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldb committed Nov 9, 2014
1 parent f90ef85 commit 68ab9b3
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
Expand Up @@ -8,7 +8,7 @@ class ContinentsController < WorldDbAdminController
def index
@continents = Continent.all

@order = params[:order] || 'title'
@order = params[:order] || 'name'
end

end # class ContinentsController
Expand Down
16 changes: 16 additions & 0 deletions engine/app/controllers/world_db_admin/places_controller.rb
@@ -0,0 +1,16 @@
# encoding: utf-8

module WorldDbAdmin

class PlacesController < WorldDbAdminController

# GET /places
def index
## nothing for now; see index.html.erb view
end


end # class PlacesController

end # module WorldDbAdmin

Expand Up @@ -14,6 +14,7 @@
<%= link_to 'Territories', territories_path() %> &bull;
<%= link_to 'Regions', regions_path() %> &bull;
<%= link_to 'Cities', cities_path() %> &bull;
<%= link_to 'Places A-Z', places_path() %> &bull;
<%= link_to 'Tags', tags_path() %> &bull;
<%= link_to 'Languages', langs_path() %> &bull;
<%= link_to 'Codes', codes_path() %> &bull;
Expand Down
38 changes: 38 additions & 0 deletions engine/app/views/world_db_admin/places/index.html.erb
@@ -0,0 +1,38 @@


<h1>Places A-Z</h1>

<% ('A'..'Z').each_with_index do |letter,i| %>
<% if i > 0 then %>
<% end %>
<%= letter %>
<% end %>
<% ('A'..'Z').each do |letter| %>

<h2><%= letter %></h2>

<% Place.where( "name like '#{letter.downcase}%'").order(:name).each do |place| %>
<div>
<%= place.name %>
<span style='font-size: 80%;'>
(<%= place.kind %>)
<% if place.kind == 'CITY'
city = City.find_by_place_id( place.id )
%>
- <%= city.country.name %>
<% if city.region %>
<%= city.region.name %>
<% end %>
<% end %>
<% if place.kind == 'ADM1'
region = Region.find_by_place_id( place.id )
%>
- <%= region.country.name %>
<% end %>
</span>
</div>
<% end %>
<% end %>
1 change: 1 addition & 0 deletions engine/config/routes.rb
Expand Up @@ -23,6 +23,7 @@
get 'territories', :to => 'countries#index_territories', :as => 'territories'


resources :places
resources :continents
resources :countries
resources :regions
Expand Down

0 comments on commit 68ab9b3

Please sign in to comment.