This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Accepts all image files and pdfs. If the upload is a pdf, it is converted to a jpg | |
#Paperclip incorporates ImageMagick. If a multipage page PDF, only the first page is converted | |
#Model | |
#here the original style needs to be given source_file_options. It's critical that the original file is not passed geometry | |
#or the resolution won't really improve | |
has_attached_file :avatar, | |
styles: lambda { |attachment| | |
styles = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActionMailer::Base | |
def dmarc(email) | |
domain = email.split('@')[1] | |
dmarc_domain = "_dmarc.#{domain}" | |
Resolv::DNS.open do |dns| | |
records = dns.getresources(dmarc_domain, Resolv::DNS::Resource::IN::TXT) | |
records.empty? ? nil : records.map(&:data).join(" ") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//= require jquery | |
//= require best_in_place | |
//= require jquery.purr | |
//= require active_admin/base | |
$(document).ready(function() { | |
$(".best_in_place").best_in_place() | |
$('.best_in_place').bind("ajax:success", function () {$(this).closest('tr').effect('highlight'); }); | |
$(document).on('best_in_place:error', function(event, request, error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Session controller provides a token | |
#/controllers/api/sessions_controller.rb | |
class Api::SessionsController < Devise::SessionsController | |
before_filter :authenticate_user!, :except => [:create] | |
before_filter :ensure_params_exist, :except => [:destroy] | |
respond_to :json | |
def create | |
resource = User.find_for_database_authentication(:email => params[:user_login][:email]) | |
return invalid_login_attempt unless resource |