I am fairly new to Rails. I am trying to launch a book review app into production. I loosely based it on an online tutorial. I have a button that supposedly will delete a "Book" entry from my app. I have a delete button on the book's show page. However, when I click to delete the book entry, it redirects to that books show page without doing anything. The button works perfectly in production.
I DID already precompile my assets. So I'm a bit confused as to what is going on.
Here is the Heroku log:
2016-10-03T18:28:09.421132+00:00 heroku[router]: at=info method=GET path="/books/3" host=seaboltapplication.herokuapp.com request_id=9c80f545-4de0-4330-9771-b97f47c49d06 fwd="69.181.73.43" dyno=web.1 connect=1ms service=106ms status=200 bytes=3350
2016-10-03T18:28:09.295950+00:00 app[web.1]: I, [2016-10-03T18:28:09.295839 #3] INFO -- : [9c80f545-4de0-4330-9771-b97f47c49d06] Started GET "/books/3" for 69.181.73.43 at 2016-10-03 18:28:09 +0000
2016-10-03T18:28:09.297370+00:00 app[web.1]: I, [2016-10-03T18:28:09.297254 #3] INFO -- : [9c80f545-4de0-4330-9771-b97f47c49d06] Processing by BooksController#show as HTML
2016-10-03T18:28:09.297509+00:00 app[web.1]: I, [2016-10-03T18:28:09.297433 #3] INFO -- : [9c80f545-4de0-4330-9771-b97f47c49d06] Parameters: {"id"=>"3"}
2016-10-03T18:28:09.318597+00:00 app[web.1]: D, [2016-10-03T18:28:09.318473 #3] DEBUG -- : [9c80f545-4de0-4330-9771-b97f47c49d06] User Load (6.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]]
2016-10-03T18:28:09.328080+00:00 app[web.1]: D, [2016-10-03T18:28:09.327992 #3] DEBUG -- : [9c80f545-4de0-4330-9771-b97f47c49d06] Book Load (3.2ms) SELECT "books".* FROM "books" WHERE "books"."id" = $1 LIMIT $2 [["id", 3], ["LIMIT", 1]]
2016-10-03T18:28:09.355978+00:00 app[web.1]: D, [2016-10-03T18:28:09.355856 #3] DEBUG -- : [9c80f545-4de0-4330-9771-b97f47c49d06] Review Load (24.8ms) SELECT "reviews".* FROM "reviews" WHERE "reviews"."book_id" = $1 [["book_id", 3]]
2016-10-03T18:28:09.357259+00:00 app[web.1]: I, [2016-10-03T18:28:09.357181 #3] INFO -- : [9c80f545-4de0-4330-9771-b97f47c49d06] Rendering books/show.html.erb within layouts/application
2016-10-03T18:28:09.384356+00:00 app[web.1]: D, [2016-10-03T18:28:09.384194 #3] DEBUG -- : [9c80f545-4de0-4330-9771-b97f47c49d06] (15.7ms) SELECT COUNT(*) FROM "reviews" WHERE "reviews"."book_id" = $1 [["book_id", 3]]
2016-10-03T18:28:09.385772+00:00 app[web.1]: I, [2016-10-03T18:28:09.385704 #3] INFO -- : [9c80f545-4de0-4330-9771-b97f47c49d06] Rendered collection of templates [0 times] (0.0ms)
2016-10-03T18:28:09.387771+00:00 app[web.1]: I, [2016-10-03T18:28:09.387705 #3] INFO -- : [9c80f545-4de0-4330-9771-b97f47c49d06] Rendered books/show.html.erb within layouts/application (28.5ms)
2016-10-03T18:28:09.395073+00:00 app[web.1]: I, [2016-10-03T18:28:09.394993 #3] INFO -- : [9c80f545-4de0-4330-9771-b97f47c49d06] Completed 200 OK in 97ms (Views: 22.4ms | ActiveRecord: 50.1ms)
2016-10-03T18:28:09.513597+00:00 app[web.1]: I, [2016-10-03T18:28:09.513474 #3] INFO -- : [85138d87-8923-459e-b5c4-0c8c8458fbf8] Started GET "/assets/application.scss" for 69.181.73.43 at 2016-10-03 18:28:09 +0000
2016-10-03T18:28:09.539647+00:00 heroku[router]: at=info method=GET path="/assets/application.scss" host=seaboltapplication.herokuapp.com request_id=85138d87-8923-459e-b5c4-0c8c8458fbf8 fwd="69.181.73.43" dyno=web.1 connect=1ms service=9ms status=304 bytes=258
2016-10-03T18:28:09.636363+00:00 heroku[router]: at=info method=GET path="/assets/application-8e81f96a4be820b7a898f27d43882ce589b4df24917971fd73bf945e1a4700db.js" host=seaboltapplication.herokuapp.com request_id=370fb212-f097-4afd-9651-0b5584845e17 fwd="69.181.73.43" dyno=web.1 connect=0ms service=1ms status=304 bytes=48
2016-10-03T18:28:09.752359+00:00 heroku[router]: at=info method=GET path="/assets/mobile.scss" host=seaboltapplication.herokuapp.com request_id=69751179-3193-4419-8ba8-a21bea0e01ea fwd="69.181.73.43" dyno=web.1 connect=0ms service=9ms status=304 bytes=258
2016-10-03T18:28:09.737788+00:00 app[web.1]: I, [2016-10-03T18:28:09.737698 #3] INFO -- : [69751179-3193-4419-8ba8-a21bea0e01ea] Started GET "/assets/mobile.scss" for 69.181.73.43 at 2016-10-03 18:28:09 +0000
Johns-MacBook-Pro:BookApp johnseabolt$
Here is my books controller: class BooksController < ApplicationController before_action :authenticate_user!, only: [:new, :edit, :index, :show]
def index
@books = Book.all
end
def new
@book = current_user.books.new
end
def create
@book = current_user.books.build(book_params)
if @book.save
redirect_to books_path
else
render 'new'
end
end
def show
@book = Book.find(params[:id])
if @book.reviews.blank?
@average_review = 0
else
@average_review = @book.reviews.average(:rating).round(2)
end
end
def edit
@book = Book.find(params[:id])
end
def update
@book = Book.find(params[:id])
if @book.update(book_params)
redirect_to book_path(@book)
else
render "edit"
end
end
def destroy
@book = Book.find(params[:id])
@book.destroy
if @book.destroy
redirect_to books_path
else
render 'show_books_path'
end
end
private
def book_params
params.require(:book).permit(:description, :author, :category_id, :book_img, :title)
end
end
Here is relevant portion of the book's show page:
<div class="inner_left">
<%= image_tag @book.book_img.url, :class => "book_show" %>
<div class="buttons">
<% if user_signed_in? then %>
<% if current_user.id = @book.user_id %>
<%= link_to "Edit", edit_book_path, :class => "btn_left" %>
<%= link_to "Delete", book_path(@book), method: :delete, :class => "btn_right", data: {confirm: "Are you sure?"} %>
<% end %>
<% end %>
<br />
<%= link_to "Back", root_path, :class => "btn" %>
<br />
<%= link_to "Add Review", new_book_review_path(@book) , :class => "btn_submit" %>
</div>
</div>
Here is the relevant section of my config/enivornments/prodection.rb file:
config.assets.compile = true