Skip to content

Instantly share code, notes, and snippets.

View jurikern's full-sized avatar

Juri Kern jurikern

View GitHub Profile
@jurikern
jurikern / Resque error description
Created May 10, 2012 20:36
Resque and resque-scheduler bug on production environment
PG::Error: ERROR: prepared statement "a3" already exists :
SELECT COUNT(*) FROM pg_class c LEFT JOIN pg_namespace n ON n.on = c.rel namespace WHERE c.relkind in ('v','r') AND c.relname = $1 AND n.nsp name = ANY (current_schema(false))
@jurikern
jurikern / Rails & Redis
Created July 9, 2012 11:52
Redis integration with Rails
http://jimneath.org/2011/03/24/using-redis-with-ruby-on-rails.html
Add to file [engine_path]/application.css
//= require twitter/bootstrap
$(document).ready(function(){
/* Your javascripts goes here... */
});
Add to file [engine_path]/application.css
/*
*= require bootstrap_and_overrides
# ==> ORM configuration in file devise.rb
require 'devise/orm/active_record'
# ==> Application configuration in application.rb
config.generators do |g|
g.orm :active_record
end
@file = YAML.load_file("#{Rails.root.join('path/to/folder', 'file.yml')}")
@jurikern
jurikern / gist:3434316
Created August 23, 2012 08:36
Dropdown list validation on rails > 3.2
class Person
validates :gender_id, :presence => true, :inclusion => { :in => proc { |req| req.gender_types.map{ |key, value| key } } } #req - self 'Person' object
validates :title_id, :presence => true, :inclusion => { :in => proc { |req| req.title_types.map{ |key, value| key } } }
end
@jurikern
jurikern / gist:3435077
Created August 23, 2012 10:07
Validation using :if or :unless conditions
class EmploymentInformation < ActiveRecord::Base
attr_accessible :employment_status_id, :company_name, :university
validates :employment_status_id, :presence => true, :inclusion => { :in => proc { |req| req.employment_status_types.map{ |key, value| key } } }
validates :company_name, :presence => true, :format => { :with => /\A[A-z\s\-\._]+\z/ }, :unless => proc { |req| req.employment_status.nil? }
validates :university, :presence => true, :format => { :with => /\A[A-z\s\-\._]+\z/ }, :unless => proc { |req| req.employment_status.nil? }
end
@jurikern
jurikern / gist:3664983
Created September 7, 2012 10:31
Regex brilliant collection
/^([0-9]{3}([0-9]{3})?|[0-9]{4})$/ -> 111. 1111, 111111
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev lib64readline-gplv2-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local
make
make install
@jurikern
jurikern / gist:3953143
Created October 25, 2012 15:03
undefined method `_prefixes' for TemplatesBuilder:Class
actionpack (3.2.8) lib/action_view/base.rb:209:in `initialize'
app/builders/templates_builder.rb:3:in `new'
app/builders/templates_builder.rb:3:in `process'
app/controllers/templates_controller.rb:6:in `create'
actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.8) lib/active_support/callbacks.rb:436:in `_run__2734696839539265386__process_action__2538432014012520187__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'