Add vote functionality to tracks
This commit is contained in:
parent
8b2f2b538e
commit
92b09c7de4
18 changed files with 237 additions and 19 deletions
|
|
@ -30,6 +30,7 @@ module Admin
|
|||
end
|
||||
|
||||
def show
|
||||
@votes = @track.votes.includes(:user)
|
||||
respond_to do |format|
|
||||
format.html { render }
|
||||
format.json { render json: @conference.tracks.to_json }
|
||||
|
|
@ -65,6 +66,24 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def vote
|
||||
@votes = @track.votes.includes(:user)
|
||||
|
||||
if (votes = current_user.votes.find_by(votable: @track))
|
||||
votes.update_attributes(rating: params[:rating])
|
||||
else
|
||||
@myvote = @track.votes.build
|
||||
@myvote.user = current_user
|
||||
@myvote.rating = params[:rating]
|
||||
@myvote.save
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to admin_conference_program_track_path(@conference.short_title, @track) }
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @track.destroy
|
||||
redirect_to admin_conference_program_tracks_path(conference_id: @conference.short_title),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue