Skip to content

Instantly share code, notes, and snippets.

@Heavyblade
Created September 3, 2013 16:06
Show Gist options
  • Select an option

  • Save Heavyblade/6425938 to your computer and use it in GitHub Desktop.

Select an option

Save Heavyblade/6425938 to your computer and use it in GitHub Desktop.
class Brochure < ActiveRecord::Base
belongs_to :property
has_many :brochure_receipts
def recipients
subscriber_ids = Subscription.where(property_type: property.property_details_type).pluck(:subscriber_id)
User.where.not(id: brochure_receipts.prospect_ids).where(id: subscriber_ids)
end
def upload_mail_template
sg = SendgridAdapter.new(ENV["SENDGRID_USERNAME"], ENV["SENDGRID_PASSWORD"])
end
def render_template
controller = ActionController::Base.new
view = ActionView::Base.new('app/views', {}, controller)
view.render(file: "properties/property_mail",:layout => false, :locals => {:property => self.property})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment