Scaffold exercise collection routes
This commit is contained in:
24
app/controllers/exercise_collections_controller.rb
Normal file
24
app/controllers/exercise_collections_controller.rb
Normal file
@ -0,0 +1,24 @@
|
||||
class ExerciseCollectionsController < ApplicationController
|
||||
|
||||
before_action :set_exercise_collection, only: [:show]
|
||||
|
||||
def index
|
||||
@exercise_collections = ExerciseCollection.all
|
||||
authorize!
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def set_exercise_collection
|
||||
@exercise_collection = ExerciseCollection.find(params[:id])
|
||||
authorize!
|
||||
end
|
||||
|
||||
def authorize!
|
||||
authorize(@exercise_collection || @exercise_collections)
|
||||
end
|
||||
end
|
3
app/policies/exercise_collection_policy.rb
Normal file
3
app/policies/exercise_collection_policy.rb
Normal file
@ -0,0 +1,3 @@
|
||||
class ExerciseCollectionPolicy < AdminOnlyPolicy
|
||||
|
||||
end
|
1
app/views/exercise_collections/index.html.slim
Normal file
1
app/views/exercise_collections/index.html.slim
Normal file
@ -0,0 +1 @@
|
||||
h1 = 'ExerciseCollections#index'
|
1
app/views/exercise_collections/show.html.slim
Normal file
1
app/views/exercise_collections/show.html.slim
Normal file
@ -0,0 +1 @@
|
||||
h1 = 'ExerciseCollection#show'
|
@ -74,6 +74,8 @@ Rails.application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
resources :exercise_collections
|
||||
|
||||
resources :proxy_exercises do
|
||||
member do
|
||||
post :clone
|
||||
|
14
test/controllers/exercise_collections_controller_test.rb
Normal file
14
test/controllers/exercise_collections_controller_test.rb
Normal file
@ -0,0 +1,14 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ExerciseCollectionsControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get show" do
|
||||
get :show
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user