- working party
- working friend - working attendent
This commit is contained in:
@ -6,6 +6,7 @@ class PartiesController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
@friends = Friend.order(:lastname, :firstname)
|
||||
end
|
||||
|
||||
def new
|
||||
@ -45,6 +46,33 @@ class PartiesController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def toggle_attendent
|
||||
member = false
|
||||
party = Party.find_by(id: params[:party_id])
|
||||
friend = Friend.find_by(id: params[:friend_id])
|
||||
|
||||
if party.attendents.exists?( friend_id: friend.id )
|
||||
puts "gefunden"
|
||||
party.attendents.where(friend_id: friend.id).delete_all
|
||||
else
|
||||
puts "nicht gefunden"
|
||||
party.attendents.create(friend_id: friend.id)
|
||||
member = true
|
||||
end
|
||||
|
||||
render turbo_stream:
|
||||
turbo_stream.replace(
|
||||
"party-#{party.id}-#{friend.id}",
|
||||
partial: 'parties/attendent',
|
||||
locals: {
|
||||
friend: friend,
|
||||
party: party,
|
||||
member: member
|
||||
}
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_party
|
||||
|
||||
Reference in New Issue
Block a user