Skip to content
Snippets Groups Projects
Commit d34cfa55 authored by Matheus Agio Nerone's avatar Matheus Agio Nerone
Browse files

adding carousels controller

parent 0779effb
No related branches found
No related tags found
No related merge requests found
# 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/
// Place all the styles related to the management/carousel controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
class Management::CarouselController < ManagementController
before_action :set_carousel, only: [:show, :create, :update, :destroy]
def index
@carousels = carousel_repository.all
end
def show
end
def new
@carousel = Carousel.new
end
def create
@carousel = Carousel.new(carousel_params)
respond_to do |format|
if @carousel.save
format.html { redirect_to management_carousel_path(@carousel), notice: "Carousel created!" }
else
format.html { render :new }
end
end
end
def update
respond_to do |format|
if carousel_repository.update(@carousel, carousel_params)
format.html { redirect_to management_carousel_path(@carousel), notice: "Carousel updated!" }
else
format.html { render :edit }
end
end
end
def destroy
carousel_repository.destroy @carousel
respond_to do |format|
format.html { redirect_to management_carousels_path, notice: "Carousel destroyed!" }
end
end
private
def carousel_repository
repository.for :carousel
end
def set_carousel
@carousel = carousel_repository.find params[:id]
end
def carousel_params
params.require(:carousel).permit(:title, :url, :image)
end
end
module Management::CarouselHelper
end
require 'test_helper'
class Management::CarouselControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment