Skip to content

Instantly share code, notes, and snippets.

@bchadfield
bchadfield / brief_pdf.rb
Created March 29, 2013 22:39
Example PDF class for Prawn
class BriefPdf < Prawn::Document
def initialize(brief, user)
super(top_margin: 70, left_margin: 80, right_margin: 80, bottom_margin: 50)
@brief = brief
@user = user
header
company
contact
project
end
<%= link_to "Upvote", vote_polls_path(poll, :vote_type => "upvotes"), :remote => true %>
<%= link_to "Downvote", vote_polls_path(poll, :vote_type => "downvotes"), :remote => true %>
# Add :vote to your set_poll before_action
def vote
@poll.increment!(params[:vote_type].to_sym) if ["upvotes", "downvotes"].include?(params[:vote_type])
end