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 ActiveSupport | |
module Cache | |
class RedisStore | |
def delete(key, options = nil) | |
options = merged_options(options) | |
instrument(:delete_matched, key.inspect) do |payload| | |
delete_matched(namespaced_key(key, options), options) | |
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
def self.me2 | |
total_count = 0 | |
total_new = Project.order(datum: :asc).group("date_format(datum, '%Y%m')").count.select{|d,c| d} | |
total_by_month = Hash[total_new.map { |month, n| [ month, total_count += n ]}] | |
end | |
def self.mike | |
new_users_by_month = Project.group("date_format(datum, '%Y%m')").count.select{|d,c| d} | |
total_users_by_month = Hash[new_users_by_month.map do |d, c| | |
[d, new_users_by_month.sum do |d2,c| |
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 save | |
ActiveRecord::Base.transaction do | |
return contact.save! && school.save! | |
end | |
rescue | |
false | |
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 Contact < ActiveRecord::Base | |
has_and_belongs_to_many :clients, class_name: "School" | |
after_save :update_primary | |
def name | |
title + " " + forename + " " + surname | |
end | |
private |
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 | |
engines | |
engine_one | |
app | |
models | |
..etc | |
engine_two | |
app | |
models | |
..etc |
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 Widget < ActiveRecord::Base | |
attr_accessible :name, :snippets, :snippets_attributes, :company_id, :hostname, :first_page, :affiliate_id, :item_defaults, :read_only | |
has_many :snippets | |
has_many :permissions, dependent: :destroy | |
has_many :users, through: :permissions | |
accepts_nested_attributes_for :snippets | |
attr_accessor :read_only | |
def read_only | |
true |
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 JTask | |
# JTask.find() | |
# Retrieves records from the database file. | |
# -------------------------------------------------------------------------------- | |
# Eg: JTask.find("test.json", 1) || JTask.find("test.json", first: 10) | |
# #=> <JTask id=x, ...> | |
# -------------------------------------------------------------------------------- | |
# See wiki guide for more usage examples... | |
# https://github.com/adammcarthur/jtask/wiki/find |
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 Party < AR::Base | |
belongs_to :user | |
belongs_to :session | |
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
resources :groups, path: '/', only: :show do | |
resources :events | |
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
def update_status | |
order_statuses = self.rows.joins(row_status: :order_status).group('order_status.id').pluck('order_status.id') | |
self.order_status_id = order_statuses.one? ? order_statuses.pop : OrderStatus.find_by(name: "processing").id | |
self.save! | |
end |