Add vote functionality to tracks

This commit is contained in:
Rishabh Singh 2019-08-09 17:33:42 +05:30
parent 8b2f2b538e
commit 92b09c7de4
18 changed files with 237 additions and 19 deletions

View file

@ -47,8 +47,8 @@ module Admin
@versions = @event.versions |
PaperTrail::Version.where(item_type: 'Commercial').where('object LIKE ?', "%commercialable_id: #{@event.id}\ncommercialable_type: Event%") |
PaperTrail::Version.where(item_type: 'Commercial').where('object_changes LIKE ?', "%commercialable_id:\n- \n- #{@event.id}\ncommercialable_type:\n- \n- Event%") |
PaperTrail::Version.where(item_type: 'Vote').where('object_changes LIKE ?', "%\nevent_id:\n- \n- #{@event.id}\n%") |
PaperTrail::Version.where(item_type: 'Vote').where('object LIKE ?', "%\nevent_id: #{@event.id}\n%")
PaperTrail::Version.where(item_type: 'Vote').where('object_changes LIKE ?', "%votable_type:\n- \n- Event\nvotable_id:\n- \n- #{@event.id}%") |
PaperTrail::Version.where(item_type: 'Vote').where('object LIKE ?', "%votable_type: Event\nvotable_id: #{@event.id}%")
end
def edit
@ -141,7 +141,7 @@ module Admin
def vote
@votes = @event.votes.includes(:user)
if (votes = current_user.votes.find_by_event_id(params[:id]))
if (votes = current_user.votes.find_by(votable: @event))
votes.update_attributes(rating: params[:rating])
else
@myvote = @event.votes.build