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 CampaignsHelper | |
COLORS = [ | |
{ percents: [-1], color: 'gray', message: 'no_capping'}, | |
{ percents: 0..30, color: 'red', message: 'msg'}, | |
{ percents: 30..70, color: 'yellow', message: 'msg'}, | |
{ percents: 70..100, color: 'green', message: 'msg'} | |
] | |
def campaign_state(draft_campaign) |
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 CountryStorage | |
private | |
# extend this module than call some constant | |
# using agreement COUNTRY_#{country_code} | |
# this will raise const_missing and than create constant COUNTRY_#{country_code} | |
# equal to Country.find_by(code: country_code) | |
# instead of using |
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
Rails.application.configure do | |
# Settings specified here will take precedence over those in config/application.rb. | |
# Code is not reloaded between requests. | |
config.cache_classes = true | |
# Eager load code on boot. This eager loads most of Rails and | |
# your application in memory, allowing both threaded web servers | |
# and those relying on copy on write to perform better. | |
# Rake tasks automatically ignore this option for performance. |
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
# STEP 3 | |
# in application.rb of your main application add | |
require "fortuna/sitemap" | |
# and then you can use it from anywhere | |
# [1] Example from console, generate sitemap for engine: | |
>> Fortuna::Sitemap.new | |
# In '/home/rossmari/Projects/ebox/public/': | |
# Fortuna::Girl Load (0.8ms) SELECT "fortuna_girls".* FROM "fortuna_girls" |
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
-# to DRY usage of bootstrap hovered table with small font that used to SHOW model attributes was created a simple DSL | |
-# can assign new table with 2 columns (attribute name, attribute value) | |
-# can add header row/rows and content rows | |
= ShowTable::TableGenerator.generate_table(self) do | |
- add_header('Название атрибута', { width: '30%' }) | |
- add_header('Значение атрибута') | |
- add_row('Имя') do |
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
# === BEFORE REFACTORING | |
# problems : include russian text, include translation, include unused code | |
#encoding: utf-8 | |
class SearchOption < ActiveRecord::Base | |
has_no_table | |
column :include, :string | |
column :field_name, :string | |
column :text, :string |
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
# === BEFORE REFACTORING | |
### При добавлении нового региона необходимо также внести информацию о поддомене в файл роутов | |
module RegionConst | |
# Местный локатив или второй предложный | |
LOCATIVE = {"Москва" => "Москве", "Кемерово" => "Кемерово"} | |
ACCUSATIVE = {"Москва" => "Москвы", "Кемерово" => "Кемерова"} | |
SUBDOMAINS = Hash[Subdomain.all(:conditions => ['title in (?)', ['Красноярск', 'Омск', 'Новосибирск', 'Абакан', 'Барнаул', 'Москва', 'Кемерово', 'Иркутск', 'Томск', 'Россия', 'Кызыл', 'В мире', 'Чита']]).map{|r| [r.title, r]}] |
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 Magazine::FormPresenter < ActiveRecord::Base | |
# === CONSTANTS | |
CONSTANT_EXCEPT = [:id, :created_at, :updated_at, :type] | |
# === COLUMN METHODS | |
class << self | |
def columns | |
@columns ||= []; | |
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
class Magazine::EventLogger | |
attr_reader :history | |
FIELD_EXCEPTIONS = [:updated_at] | |
@namespace = 'Magazine::' | |
@suffix = 'Event' | |
def initialize(object) |
NewerOlder