Sha256: b357dfa04a4f43aad4b3823d765fe45aa80655fc0b8b7e5a7d946fbc2835d9ed
Contents?: true
Size: 493 Bytes
Versions: 10
Compression:
Stored size: 493 Bytes
Contents
module VotesControllerHelpers def create(voteable) xhr :post, :create, vote: { voteable_type: voteable.class.name, voteable_id: voteable.id, value: rand(0..1) } end def update(vote, duplicate=false) xhr :patch, :update, id: vote.id, value: value(vote.value, duplicate) end def destroy(vote) xhr :delete, :destroy, id: vote.id end private def value(val, duplicate) return val if duplicate val == 1 ? 0 : 1 end end
Version data entries
10 entries across 10 versions & 1 rubygems