Newer
Older
class LearningObjectsController < ApplicationController
before_action :set_learning_object, only: [:show, :edit, :update, :destroy]
# GET /learning_objects
# GET /learning_objects.json
@learning_objects = repository.for(:learning_object).all
# GET /learning_objects/1
# GET /learning_objects/1.json
unless @learning_object.nil?
@like_counts = repository.for(:edge).get_in_edges_count "Likes", @learning_object.id
# GET /learning_objects/new
@learning_object = repository.for(:learning_object).new
# GET /learning_objects/1/edit
def edit
# POST /learning_objects
# POST /learning_objects.json
def create
@learning_object = repository.for(:learning_object).new(learning_object_params)
respond_to do |format|
if @learning_object.save
format.html { redirect_to @learning_object, notice: 'Learning object was successfully created.' }
format.json { render :show, status: :created, location: @learning_object }
else
format.html { render :new }
format.json { render json: @learning_object.errors, status: :unprocessable_entity }
end
end
# PATCH/PUT /learning_objects/1
# PATCH/PUT /learning_objects/1.json
respond_to do |format|
if @learning_object.update(learning_object_params)
format.html { redirect_to @learning_object, notice: 'Learning object was successfully updated.' }
format.json { render :show, status: :ok, location: @learning_object }
else
format.html { render :edit }
format.json { render json: @learning_object.errors, status: :unprocessable_entity }
end
end
# DELETE /learning_objects/1
# DELETE /learning_objects/1.json
@learning_object.destroy
respond_to do |format|
format.html { redirect_to learning_objects_url, notice: 'Learning object was successfully destroyed.' }
format.json { head :no_content }
end
private
# Use callbacks to share common setup or constraints between actions.
def set_learning_object
@learning_object = repository.for(:learning_object).get_by_dspaceid params[:id]
end
# Never trust parameters from the scary internet, only allow the white list through.
def learning_object_params
params[:learning_object]
end