Skip to content

Commit

Permalink
Merge pull request #46 from IliaZolas/destroy
Browse files Browse the repository at this point in the history
Delete booking and studios
  • Loading branch information
IliaZolas authored Nov 27, 2020
2 parents 1d9d491 + 436b7b5 commit f351957
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/controllers/bookings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def booking_manager
@studios = Studio.where(user: current_user)
end

def destroy
@booking = Booking.find(params[:id])
@booking.destroy
redirect_to my_bookings_path
end

private

def booking_params
Expand Down
8 changes: 7 additions & 1 deletion app/controllers/studios_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@ def create
end
end

def studio_manager
def studio_manager
# binding.pry
@studios = Studio.where(user: current_user)
end

def destroy
@studio = Studio.find(params[:id])
@studio.destroy
redirect_to my_studios_path
end

private

def studio_params
Expand Down
6 changes: 6 additions & 0 deletions app/views/bookings/booking_manager.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
<div class="total-price">
<h2><strong>Total Price: <%= booking.total_price %>Chf</strong></h2>
</div>
<p class='btn btn-lg btn-primary'>
<%= link_to "Delete",
booking_path(booking),
method: :delete,
data: {confirm: "Are you sure?"} %>
</p>
</div>
<% end %>
</div>
Expand Down
6 changes: 6 additions & 0 deletions app/views/studios/studio_manager.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
<% if studio.photo.attached? %>
<%= cl_image_tag studio.photo.key, class: "card-img-top", height: 180 %>
<% end %>
<p class='btn btn-lg btn-primary'>
<%= link_to "Delete",
studio_path(studio),
method: :delete,
data: {confirm: "Are you sure?"} %>
</p>
</div>
<% end %>
</div>
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
resources :bookings, only:[:destroy]
get "/my_bookings", to: "bookings#booking_manager"
get "/my_studios", to: "studios#studio_manager"
resources :studios, only:[:destroy]
end

0 comments on commit f351957

Please sign in to comment.