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 ApplicationController < ActionController::Base | |
rescue_from Exception do |exception| | |
logger.error exception.backtrace.join("\n") | |
head 500 | |
end | |
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 User < ActiveRecord::Base | |
def find_form(id) | |
company.forms.find(id) | |
end | |
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 ApplicationController < ActionController::Base | |
rescue_from 'Exception' do |exception| | |
logger.info exception | |
logger.info exception.backtrace.join("\n") | |
render :head => 500 | |
end | |
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
rake aborted! | |
ruby /home/marko/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -S rspec ./spec/helpers/sessions_helper_spec.rb ./spec/helpers/users_helper_spec.rb | |
<<other spec files>> failed | |
/home/marko/devel/foo/vendor/bundle/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/rake_task.rb:149:in `block (2 levels) in initialize' | |
/home/marko/devel/foo/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1112:in `verbose' | |
/home/marko/devel/foo/vendor/bundle/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/rake_task.rb:139:in `block in initialize' | |
/home/marko/devel/foo/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in `call' | |
/home/marko/devel/foo/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in `block in execute' | |
/home/marko/devel/foo/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in `each' | |
/home/marko/devel/foo/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in `execute' |
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 ApplicationHelper | |
# In your layout: <body <%= render_page_data %>> | |
# | |
def render_page_data | |
@page_data_attributes.html_safe if @page_data_attributes.present? | |
end | |
# Appends a hash of data attributes to the body element. For example: | |
# |
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 do_it(options = {}) | |
puts options.inspect | |
end | |
# new syntax: | |
do_it(user_type: :vip) | |
# => {:user_type=>:vip} | |
# old syntax | |
do_it(:user_type => :vip) |
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
# in your routes.rb: | |
# devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } | |
# | |
# and view: | |
# link_to("Connect to LinkedIn", user_omniauth_authorize_path(:linked_in)) | |
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | |
def linkedin | |
omniauth_hash = env["omniauth.auth"] |
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
# See https://gist.github.com/1151655 for a tip how to save access token and secret in an omniauth callback. | |
class LinkedinFactory | |
API_KEY = "123" | |
SECRET_KEY = "456" | |
def self.authorize_user(user) | |
token = user.linkedin_connection.token | |
secret = user.linkedin_connection.secret |
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
*filter | |
# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0 | |
-A INPUT -i lo -j ACCEPT | |
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT | |
# Accepts all established inbound connections | |
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT |
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
# use this in a after "deploy:update_code" block | |
namespace :bundler do | |
task :create_symlink, :roles => :app do | |
shared_dir = File.join(shared_path, 'bundle') | |
release_dir = File.join(current_release, '.bundle') | |
run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}") | |
end | |
task :bundle_new_release, :roles => :app do |