mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-05 14:17:20 +00:00
Start of api
This commit is contained in:
3
app/assets/javascripts/api.js.coffee
Normal file
3
app/assets/javascripts/api.js.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
4
app/assets/stylesheets/api.css
Normal file
4
app/assets/stylesheets/api.css
Normal file
@@ -0,0 +1,4 @@
|
||||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
||||
10
app/controllers/api_controller.rb
Normal file
10
app/controllers/api_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class ApiController < ApplicationController
|
||||
|
||||
def tournaments
|
||||
@tournaments = Tournament.all
|
||||
end
|
||||
|
||||
def tournament
|
||||
@tournament = Tournament.where(:id => params[:tournament]).includes(:schools,:weights,:mats,:matches,:user,:wrestlers).first
|
||||
end
|
||||
end
|
||||
2
app/helpers/api_helper.rb
Normal file
2
app/helpers/api_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module ApiHelper
|
||||
end
|
||||
1
app/views/api/tournament.jbuilder
Normal file
1
app/views/api/tournament.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.(@tournament, :id, :name, :address, :director, :director_email, :schools, :weights, :mats, :matches)
|
||||
4
app/views/api/tournaments.jbuilder
Normal file
4
app/views/api/tournaments.jbuilder
Normal file
@@ -0,0 +1,4 @@
|
||||
json.array!(@tournaments) do |tournament|
|
||||
json.extract! tournament, :id, :name, :address, :director, :director_email
|
||||
json.url tournament_url(tournament, format: :json)
|
||||
end
|
||||
Reference in New Issue
Block a user