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
# GOOD - check if can object be destroyed and when it's possible destroy associated objects :-) | |
before_destroy :can_be_removed? | |
has_many :custom_values, dependent: :destroy | |
# BAD - destroys associated objects and then check if object can be destroyed :-( | |
has_many :custom_values, dependent: :destroy | |
before_destroy :can_be_removed? |
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
window.localeEn = { | |
menu: { | |
secrets_of_newtown: 'Secrets of Newtown', | |
your_investigation: 'Your Adventure', | |
einder_story: 'Einder\'s Story', | |
rumors: 'Rumors' | |
}, | |
read_story: 'Read Story', | |
subtitle: 'intriguing location based game<br/>settled in the world of H.P. Lovecraft', | |
newtown_section: { |
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 ActiveJob | |
module Enqueuing | |
module ClassMethods | |
def remove_delayed(*args) | |
job_or_instantiate(*args).remove_delayed | |
end | |
end | |
def remove_delayed | |
self.class.queue_adapter.remove_delayed(self) |
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 'yaml' | |
example_vars = YAML.load_file('config/application.example.yml').keys | |
live_vars = Rails.env.production? ? (ENV.keys & example_vars) : YAML.load_file('config/application.yml').keys | |
unless live_vars.sort == example_vars.sort | |
raise 'There is a mismatch between application.yml and application.example.yml' | |
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
def send_changes(bid_id) | |
tender_diff = {label: 'Voice of Poland', name: ['Voice of Poland', 'X-Factor'], currency: ['EUR', 'PLN']} | |
item_diffs = [{label: 'Golf Ball', name: ['Golf Ball', 'Football Ball'], quantity: [4,5]},{label: 'Chess Board', name: ['Chess | |
Board', 'Agile Board']}] | |
diffs = {tender_diff: tender_diff, item_diffs: item_diffs} | |
EmailDelivery.deliver bid_id, diffs, {action: 'tender_changed_for_supplier'} | |
end | |
send_changes(bid_id) |
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
namespace :server_db do | |
task :migrate, :roles => :app do | |
run "cd #{release_path} && RAILS_ENV=production rake db:migrate" | |
end | |
task :get, :roles => :app do | |
puts "This task is designed to get database from the server" | |
puts "Example: cap ENV server_db:get" | |
t = Time.now | |
db_name = "pg_dump_#{environment}_%04d%02d%02d_%02d%02d%02d.sql" % [t.year, t.month, t.day, t.hour, t.min, t.sec] |
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
= content_tag :div, id: 'destroy_confirmation' do | |
= content_tag :div, class: 'colorbox-head' do | |
= content_tag :h2, options[:title] || t("global.confirm_title") | |
= content_tag :div, class: 'colorbox-body' do | |
= content_tag :p, options[:message] || t('global.confirm') | |
= content_tag :div, class: 'colorbox-foot' do | |
= link_to t('global.yes'), confirmed_url, | |
method: (options[:method] || 'GET'), | |
remote: options[:remote], | |
class: 'bt bt-primary' |
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 PerformedActions | |
module Base | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
def perform_action(action) | |
if self.class.get_performable_actions.include?(action.to_s) | |
PerformedAction.create!(subject: self, | |
performer_id: PerformedAction.current_user.try(:id), |
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
var config = { | |
labelField: '#label_input' | |
valueField: '#value_input', | |
source: '/path_to_autocompleter_backend', //responds with json [{label: '...', value: '...'}, {label: '...', value: '...'}] | |
focus: function(event, ui) { | |
var self = config; | |
$(self.field).val( ui.item.label ); | |
return false; | |
}, | |
change: function(event, ui){ |
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
# lib/modules/suggestions_for_field.rb | |
module SuggestionsByField | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def suggestions_for_field(field, query) | |
connection.execute(" | |
select val from ( |