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
if Rails.env.production? | |
PAYPAL_ACCOUNT = '[email protected]' | |
else | |
PAYPAL_ACCOUNT = '[email protected]' | |
ActiveMerchant::Billing::Base.mode = :test | |
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
Example::Application.configure do | |
.... | |
ActionMailer::Base.delivery_method = :smtp | |
ActionMailer::Base.smtp_settings = {:address => "localhost", :port => 1025, :domain => 'example.com'} | |
... | |
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
custom = ::Mail.new(raw_email) | |
key = Rails.application.config.action_mailer.delivery_method | |
delivery_method = ActionMailer::Base.delivery_methods.fetch(key) | |
delivery_settings = ActionMailer::Base.send("#{key}_settings") | |
custom.delivery_method(delivery_method, delivery_settings) | |
custom.deliver |
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
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
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 Avatar < ActiveRecord::Base | |
attr_accessor :content_type, :original_filename, :image_data | |
before_save :decode_base64_image | |
has_attached_file :image, | |
PAPERCLIP_CONFIG.merge( | |
:styles => { | |
:thumb => '32x32#', | |
:medium => '64x64#', |
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 'rubygems' | |
require 'rubygems/package' | |
require 'zlib' | |
require 'fileutils' | |
module Util | |
module Tar | |
# Creates a tar file in memory recursively | |
# from the given path. | |
# |
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
PROMPT='%{$fg_bold[blue]%}$(git_prompt_info) %{$reset_color%}%2~%B%{$fg_bold[red]%} »%b ' | |
RPROMPT='[%*]' | |
ZSH_THEME_GIT_PROMPT_PREFIX="(%{$fg[green]%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%b%{$fg_bold[blue]%})%{$reset_color%}" |
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
# download and make Redis | |
$ wget http://redis.googlecode.com/files/redis-2.6.7.tar.gz | |
$ sudo tar xzf redis-2.6.7.tar.gz -C /usr/lib/ | |
$ cd /usr/lib/redis-2.6.7 | |
$ sudo make | |
# create symlinks to the /usr/local/bin | |
$ sudo ln -s /usr/lib/redis-2.6.7/src/redis-server /usr/local/bin/redis-server | |
$ sudo ln -s /usr/lib/redis-2.6.7/src/redis-cli /usr/local/bin/redis-cli |
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 | |
# ... | |
unless Rails.application.config.consider_all_requests_local | |
rescue_from Exception, with: lambda { |exception| render_error 500, exception } | |
rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception } | |
end | |
private | |
def render_error(status, exception) |
NewerOlder