rubocop corrections

This commit is contained in:
Karol Selak 2021-03-22 03:16:29 +01:00
parent c63c6bc448
commit de29815686
72 changed files with 468 additions and 311 deletions

View file

@ -1,26 +1,25 @@
# frozen_string_literal: true
# Books controller
class BooksController < ApplicationController
before_action :set_book, only: [:show, :edit, :update, :add_to_cart]
before_action :ensure_admin, only: [:edit, :update]
before_action :set_book, only: %i[show edit update add_to_cart]
before_action :ensure_admin, only: %i[edit update]
def index
if current_user&.admin?
books = Book.all
else
books = Book.published
end
books = if current_user&.admin?
Book.all
else
Book.published
end
@books = books.map { |book| BooksPresenter.new(book) }
end
def show
end
def show; end
def edit
end
def edit; end
def update
if @book.update(book_params)
redirect_to '/books'
end
redirect_to '/books' if @book.update(book_params)
end
def add_to_cart