mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
upto 2.11
This commit is contained in:
@@ -7,8 +7,15 @@ class RatingsController < ApplicationController
|
|||||||
@rating = Rating.new
|
@rating = Rating.new
|
||||||
@beers = Beer.all
|
@beers = Beer.all
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
Rating.create params.require(:rating).permit(:score, :beer_id)
|
Rating.create params.require(:rating).permit(:score, :beer_id)
|
||||||
redirect_to ratings_path
|
redirect_to ratings_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
rating = Rating.find params[:id]
|
||||||
|
rating.delete
|
||||||
|
redirect_to ratings_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,11 +4,12 @@
|
|||||||
<% @ratings.each do |rating| %>
|
<% @ratings.each do |rating| %>
|
||||||
<li>
|
<li>
|
||||||
<%= render rating %>
|
<%= render rating %>
|
||||||
|
<%= button_to "delete", rating_path(rating.id), method: :delete, form: { data: { turbo_confirm: "Are you sure?" }} %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= link_to "New rating", ratings_new_path %>
|
<%= link_to "New rating", new_rating_path %>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
+1
-3
@@ -6,7 +6,5 @@ Rails.application.routes.draw do
|
|||||||
# Defines the root path route ("/")
|
# Defines the root path route ("/")
|
||||||
# root "articles#index"
|
# root "articles#index"
|
||||||
get '/', to: 'breweries#index'
|
get '/', to: 'breweries#index'
|
||||||
get 'ratings', to: 'ratings#index'
|
resources :ratings, only: [:index, :new, :create, :destroy]
|
||||||
post 'ratings', to: 'ratings#create'
|
|
||||||
get 'ratings/new', to: 'ratings#new'
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user