Skip to content

Commit cfbaacb

Browse files
authored
Merge pull request #1433 from coderdojo-japan/add-internal-api-for-dojos
📝 Add internal Dojo API to write News article much easier
2 parents 53a9c55 + f48e7eb commit cfbaacb

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

app/controllers/dojos_controller.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class DojosController < ApplicationController
2+
def index
3+
@dojo_data = []
4+
Dojo.active.each do |dojo|
5+
@dojo_data << {
6+
name: dojo.name,
7+
url: dojo.url,
8+
prefecture: dojo.prefecture.region,
9+
linked_text: "<a href='#{dojo.url}'>'#{dojo.name}</a>(#{dojo.prefecture.region})",
10+
}
11+
end
12+
13+
respond_to do |format|
14+
format.json { render json: @dojo_data }
15+
16+
# No corresponding View for now.
17+
# Only for API: GET /dojos.json
18+
format.html { redirect_to root_url(anchor: 'dojos') }
19+
end
20+
end
21+
end

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
get "/kata" => "docs#kata"
5252
#get "/debug/kata" => "docs#kata"
5353

54-
54+
resources :dojos, only: %i(index) # Only API: GET /dojos.json
5555
resources :docs, only: %i(index show)
5656
resources :podcasts, only: %i(index show)
5757
resources :spaces, only: %i(index)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy