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
# Bootstrap 4 (wraps in an li and applys the active class to the li) | |
def active_link_to(name, path) | |
active_class = "active" if current_page?(path) | |
content_tag(:li, class: "nav-item #{active_class}") do | |
link_to(name, path, class: "nav-link") | |
end | |
end | |
# Anything else | |
def active_link_to(name, path) |
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
module CsvExporter | |
def self.export_results(results) | |
folder = Rails.root.join("public", "csv_exports") | |
FileUtils.mkdir_p(folder) | |
filepath = folder.join("csv_export_#{DateTime.now.to_i}.csv") | |
CSV.open(filepath, "wb") do |csv| | |
csv << self.headers | |
results.each do |result| | |
csv << self.format_row(result) |
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
API_KEY = Rails.application.secrets.mailchimp_api_key | |
LIST_ID = Rails.application.secrets.mailchimp_list_id | |
BASE_URL = 'https://us17.api.mailchimp.com/3.0'.freeze | |
AUTH = { username: 'apikey', password: API_KEY } | |
module Mailchimp | |
include HTTParty | |
def self.subscribe(first_name, last_name, email) | |
request_url = "#{BASE_URL}/lists/#{LIST_ID}/members" |
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 CsvImporterJob < ApplicationJob | |
queue_as :default | |
# Handle any cleanup after perform | |
after_perform { |job| clean_up_csv_upload(job) } | |
def perform(file, user) | |
# Use begin/rescue - raise StandardError in importer if something goes wrong | |
# Rescue here with email notification to user | |
begin |
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
default: &default | |
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> | |
development: | |
<<: *default | |
test: | |
<<: *default | |
staging: |
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
def require_admin | |
return if current_user.admin? | |
redirect_to root_path, notice: "Only admins can access this area" | |
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
config.include FactoryBot::Syntax::Methods | |
config.include Devise::Test::ControllerHelpers, type: :controller | |
config.include Devise::Test::ControllerHelpers, type: :view | |
config.include Devise::Test::IntegrationHelpers, type: :feature |
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 'rails_helper' | |
RSpec.feature 'User Registration', type: :feature do | |
let(:new_user) { FactoryBot.build(:user) } | |
let(:user) { FactoryBot.create(:user) } | |
scenario 'User can sign up' do | |
visit root_path | |
first(:link, 'Sign up').click | |
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
'use strict'; | |
const puppeteer = require('puppeteer'); | |
const fs = require('fs'); //Filesystem | |
let content = fs.readFileSync(process.argv[2], "utf-8"); | |
const createPdf = async() => { | |
let browser; | |
try { |
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 'rails_helper' | |
RSpec.feature "Groups", type: :feature do | |
let(:user) { FactoryBot.create(:user) } | |
let(:admin) { FactoryBot.create(:user, :with_admin) } | |
let(:group) { FactoryBot.create(:group) } | |
let(:groups) { FactoryBot.create_list(:group, 2) } | |
let(:new_group) { FactoryBot.build(:group) } | |
scenario 'require authentication' do |
OlderNewer