Skip to content

Commit

Permalink
Merge pull request #1433 from coderdojo-japan/add-internal-api-for-dojos
Browse files Browse the repository at this point in the history
📝 Add internal Dojo API to write News article much easier
  • Loading branch information
yasulab committed May 17, 2022
2 parents 53a9c55 + f48e7eb commit cfbaacb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions app/controllers/dojos_controller.rb
@@ -0,0 +1,21 @@
class DojosController < ApplicationController
def index
@dojo_data = []
Dojo.active.each do |dojo|
@dojo_data << {
name: dojo.name,
url: dojo.url,
prefecture: dojo.prefecture.region,
linked_text: "<a href='#{dojo.url}'>'#{dojo.name}</a>(#{dojo.prefecture.region})",
}
end

respond_to do |format|
format.json { render json: @dojo_data }

# No corresponding View for now.
# Only for API: GET /dojos.json
format.html { redirect_to root_url(anchor: 'dojos') }
end
end
end
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -51,7 +51,7 @@
get "/kata" => "docs#kata"
#get "/debug/kata" => "docs#kata"


resources :dojos, only: %i(index) # Only API: GET /dojos.json
resources :docs, only: %i(index show)
resources :podcasts, only: %i(index show)
resources :spaces, only: %i(index)
Expand Down

0 comments on commit cfbaacb

Please sign in to comment.