This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) |
NewerOlder