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
<%# /app/views/layouts/application.html.erb %> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>RyancondronPhotography</title> | |
<%= csrf_meta_tags %> | |
<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> | |
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> | |
</head> |
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
# frozen_String_literal: true | |
class Thing < ApplicationRecord | |
validates :name, presence: true | |
# can use before_create, before_save, before_update, after_save, after_create, | |
# after_update, before_validation, after_validation | |
# also accepts if/unless | |
before_save :set_bool #, if: proc { |thing| thing.name == 'TEST' } | |
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 UpdateCounterCacheJob < ApplicationJob attr_accessor :cache_columns | |
def perform(key = 'all') | |
self.cache_columns = counter_cache_hash | |
if key == 'all' | |
cache_columns.keys.each { |obj| update_cache_columns(obj) } | |
else | |
update_cache_columns(key) | |
end | |
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
{ "category": [ "article_categories" ] } |
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
RSpec.describe UpdateCounterCachesJob, type: :job do | |
it 'updates all cache columns when they are out of sync' do sql = <<-SQL update categories SET articles_count = 5 SQL | |
category = create(:category) | |
ActiveRecord::Base.connection.execute(sql) | |
category.reload | |
expect(category.articles_count).to eq(5) | |
UpdateCounterCachesJob.perform_now | |
category.reload | |
expect(category.articles_count).to eq(0) | |
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
class Category < ApplicationRecord | |
has_many :article_categories, class_name: ArticleCategory, foreign_key: :category_id, dependent: :destroy | |
has_many :articles, through: :article_categories | |
end | |
class Article < ApplicationRecord | |
belongs_to :author, class_name: User, foreign_key: :author_id | |
has_many :article_categories, class_name: ArticleCategory, foreign_key: :article_id, dependent: :destroy | |
has_many :categories, through: :article_categories | |
has_many :images, class_name: ArticleImage, foreign_key: :article_id, dependent: :destroy |
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
using System; | |
using System.Linq; | |
using System.Text; | |
using SMBLibrary; | |
namespace FileShare.Access | |
{ | |
public interface IClientDTO | |
{ | |
string IPAddress { get; set; } |
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
using System; | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using Microsoft.EntityFrameworkCore; | |
namespace DataConverter | |
{ | |
class Program | |
{ | |
static string NpgsqlConnectionString => Environment.GetEnvironmentVariable("PSQL_CONN"); |
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
using Microsoft.EntityFrameworkCore; | |
namespace DataConverter | |
{ | |
public class DataConverterContext : DbContext | |
{ | |
public DbSet<User> Users { get; set; } | |
public DataConverterContext(DbContextOptions opts) : base(opts) { } |