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

fix index view from carousel controller

parent 733b4ffb
No related branches found
No related tags found
No related merge requests found
Showing
with 106 additions and 9 deletions
class Management::CarouselController < ManagementController class Management::CarouselsController < ManagementController
before_action :set_carousel, only: [:show, :create, :update, :destroy] before_action :set_carousel, only: [ :update, :destroy]
def index def index
@carousels = carousel_repository.all @carousels = carousel_repository.all
end end
def show
end
def new def new
@carousel = Carousel.new @carousel = Carousel.new
end end
...@@ -17,7 +14,7 @@ class Management::CarouselController < ManagementController ...@@ -17,7 +14,7 @@ class Management::CarouselController < ManagementController
respond_to do |format| respond_to do |format|
if @carousel.save if @carousel.save
format.html { redirect_to management_carousel_path(@carousel), notice: "Carousel created!" } format.html { redirect_to management_carousels_path, notice: "Carousel created!" }
else else
format.html { render :new } format.html { render :new }
end end
...@@ -27,7 +24,7 @@ class Management::CarouselController < ManagementController ...@@ -27,7 +24,7 @@ class Management::CarouselController < ManagementController
def update def update
respond_to do |format| respond_to do |format|
if carousel_repository.update(@carousel, carousel_params) if carousel_repository.update(@carousel, carousel_params)
format.html { redirect_to management_carousel_path(@carousel), notice: "Carousel updated!" } format.html { redirect_to management_carousels_path, notice: "Carousel updated!" }
else else
format.html { render :edit } format.html { render :edit }
end end
...@@ -35,6 +32,7 @@ class Management::CarouselController < ManagementController ...@@ -35,6 +32,7 @@ class Management::CarouselController < ManagementController
end end
def destroy def destroy
@carousel.image = nil
carousel_repository.destroy @carousel carousel_repository.destroy @carousel
respond_to do |format| respond_to do |format|
format.html { redirect_to management_carousels_path, notice: "Carousel destroyed!" } format.html { redirect_to management_carousels_path, notice: "Carousel destroyed!" }
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
class ActiveRecord::CarouselRepository class ActiveRecord::CarouselRepository
def method_missing(method_name, *arguments, &block) def method_missing(method_name, *arguments, &block)
User.send(method_name, *arguments, &block) Carousel.send(method_name, *arguments, &block)
end end
def respond_to?(method_name, include_private = false) def respond_to?(method_name, include_private = false)
User.respond_to?(method_name) || super Carousel.respond_to?(method_name) || super
end end
end end
<%= form_for([:management, @carousel], html: {class: 'ls-form row'}) do |f| %>
<% if @carousel.errors.any? %>
<div class="ls-alert-danger">
<h2><%= pluralize(@carousel.errors.count, "erro") %> <%= "happened".pluralize(@carousel.errors.count) %>:</h2>
<ul>
<% @carousel.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<fieldset>
<label class="ls-label col-md-3">
<b class="ls-label-text">Título</b>
<p>Digite o titulo deste destaque</p>
<%= f.text_field :title, {required: true} %>
</label>
<label class="ls-label col-md-5">
<b class="ls-label-text">URL</b>
<p>Digite a URL que o usuário será redirecionado</p>
<%= f.url_field :url, {required: true} %>
</label>
<label class="ls-label col-md-5">
<b class="ls-label-text">Imagem</b>
<p>Escolha uma imagem para o destaque</p>
<%= f.file_field :image %>
</label>
</fieldset>
<div class="ls-actions-btn">
<button class="ls-btn">Salvar</button>
<%= link_to "Cancelar", management_carousels_path,class: "ls-btn-danger"%>
</div>
<% end %>
<h1 class="ls-title-intro ls-ico-users">Carousels</h1>
<ol class="ls-breadcrumb">
<li><%= link_to 'Carousels', management_carousels_path %></li>
<li>Administrar</li>
</ol>
<%= render 'form' %>
<h1 class="ls-title-intro ls-ico-users">Carousels</h1>
<a href="<%= new_management_carousel_path %>" class="ls-btn-primary" aria-expanded="false" role="combobox">Cadastrar
novo</a>
<table class="ls-table">
<thead>
<tr>
<th>
Imagem
</th>
<th>Título</th>
<th>
URL
</th>
<th>
</th>
<th></th>
</tr>
</thead>
<tbody>
<% @carousels.each do |c| %>
<tr>
<td>
<%= image_tag c.image.url(:thumbnail) %>
</td>
<td>
<%= c.title %>
</td>
<td>
<%= c.url %>
</td>
<td class="ls-txt-right ls-regroup">
<%= link_to 'Excluir', management_carousel_path(c), {method: :delete, data: {confirm: 'Tem certeza que deseja excluir?'}, title: 'Apagar usuário', class: 'ls-color-danger', role: 'option'} %>
</td>
</tr>
<% end %>
</tbody>
</table>
<h1 class="ls-title-intro ls-ico-users">Usuários</h1>
<ol class="ls-breadcrumb">
<li><a href="#">Usuários</a></li>
<li>Novo usuário</li>
</ol>
<%= render 'form' %>
\ No newline at end of file
public/system/carousels/images/000/000/002/larger/images.jpg

2.17 KiB

public/system/carousels/images/000/000/002/original/images.jpg

2.17 KiB

public/system/carousels/images/000/000/002/thumbnail/images.jpg

1.52 KiB

public/system/carousels/images/000/000/003/larger/images.jpg

2.17 KiB

public/system/carousels/images/000/000/003/original/images.jpg

2.17 KiB

public/system/carousels/images/000/000/003/thumbnail/images.jpg

1.52 KiB

public/system/carousels/images/000/000/005/larger/images.jpg

2.17 KiB

public/system/carousels/images/000/000/005/original/images.jpg

2.17 KiB

public/system/carousels/images/000/000/005/thumbnail/images.jpg

1.52 KiB

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