Skip to content

Instantly share code, notes, and snippets.

View alecslupu's full-sized avatar
🎯
Focusing

Alexandru Emil Lupu alecslupu

🎯
Focusing
View GitHub Profile
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
upstream upstream_name {
server localhost:8022;
}
server {
listen 80;
server_name payments.myhost;
access_log /var/log/nginx/www.host.access.log;
[ 2013-05-28 12:34:40.8922 17380/7fa94cdd1700 Pool2/Implementation.cpp:1156 ]: [App 17417 stderr]
[ 2013-05-28 12:34:40.8923 17380/7fa94cdd1700 Pool2/Implementation.cpp:1156 ]: [App 17417 stderr] ActionController::RoutingError (No route matches [GET] "/%c2%adadvertisers/%c2%adwinning-%c2%admoves"):
[ 2013-05-28 12:34:40.8923 17380/7fa94cdd1700 Pool2/Implementation.cpp:1156 ]: [App 17417 stderr] actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
[ 2013-05-28 12:34:40.8923 17380/7fa94cdd1700 Pool2/Implementation.cpp:1156 ]: [App 17417 stderr] actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
[ 2013-05-28 12:34:40.8923 17380/7fa94cdd1700 Pool2/Implementation.cpp:1156 ]: [App 17417 stderr] railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
[ 2013-05-28 12:34:40.8923 17380/7fa94cdd1700 Pool2/Implementation.cpp:1156 ]: [App 17417 stderr] railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
[ 2013-05-28 12:34:40.8924 1738
class MyController < ApplicationController
def redirect_to_home
true
end
end
my test
describe MyController do
@alecslupu
alecslupu / gist:5487429
Created April 30, 2013 08:40
Basic HABTM
class User < ActiveRecord::Base
has_and_belongs_to_many :skills
end
class Skill < ActiveRecord::Base
has_and_belongs_to_many :users
end
class CreateSkillsUsers < ActiveRecord::Migration
class Task < ActiveRecord::Base
belongs_to :pending_tasks_in_project, :inverse_of => :pending_tasks,
:class_name => 'Project',:foreign_key => :project_id,
:counter_cache => :pending_tasks_count
belongs_to :opened_tasks_in_project, :inverse_of => :opened_tasks,
:class_name => 'Project',:foreign_key => :project_id,
:counter_cache => :opened_tasks_count
belongs_to :closed_tasks_in_project, :inverse_of => :closed_tasks,
:class_name => 'Project', :foreign_key => :project_id,
def get_bread_crumb(url)
begin
breadcrumb = ''
so_far = '/'
elements = url.split('/')
for i in 1...elements.size
so_far += elements[i] + '/'
if elements[i] =~ /^[0-9]*$/
module Devise
module Models
# Registerable is responsible for everything related to registering a new
# resource (ie user sign up).
module Registerable
extend ActiveSupport::Concern
module ClassMethods
# A convenience method that receives both parameters and session to
# initialize a user. This can be used by OAuth, for example, to send
@alecslupu
alecslupu / gist:1360276
Created November 12, 2011 09:09
wrong number of arguments (2 for 1)
activerecord (3.1.1) lib/active_record/relation.rb:111:in `find_by_sql'
activerecord (3.1.1) lib/active_record/relation.rb:111:in `origin_to_a'
/Users/alecs/.rvm/gems/ruby-1.8.7-p352@myproject/bundler/gems/bullet-a7ddd69203a1/lib/bullet/active_record31.rb:11:in `to_a'
activerecord (3.1.1) lib/active_record/relation/finder_methods.rb:376:in `find_first'
activerecord (3.1.1) lib/active_record/relation/finder_methods.rb:122:in `first'
activerecord (3.1.1) lib/active_record/relation/finder_methods.rb:263:in `send'
activerecord (3.1.1) lib/active_record/relation/finder_methods.rb:263:in `find_by_attributes'
activerecord (3.1.1) lib/active_record/base.rb:1063:in `send'
activerecord (3.1.1) lib/active_record/base.rb:1063:in `method_missing'
actionpack (3.1.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
abstract (1.0.0)
actionmailer (3.0.7)
actionpack (3.0.7)
activemodel (3.0.7)
activerecord (3.0.7)
activeresource (3.0.7)
activesupport (3.0.7)
arel (2.0.9)
bcrypt-ruby (2.1.4)
builder (2.1.2)