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 update_with_password(params={}) | |
current_password = params.delete(:current_password) | |
params.delete(:password) if params[:password].blank? | |
params.delete(:password_confirmation) if params[:password_confirmation].blank? | |
skip_password_check = !(current_password.present? || params[:password] || params[:password_confirmation]) | |
result = if skip_password_check || valid_password?(current_password) | |
update_attributes(params) |
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
source :gemcutter | |
gem 'rails', '2.3.4', :require => nil | |
gem 'mysql' |
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
backend default { | |
.host = "127.0.0.1"; | |
.port = "8000"; | |
} | |
sub vcl_recv { | |
if (req.request != "GET" | |
&& req.request != "HEAD") { | |
return (pass); | |
} |
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 Devise | |
module Models | |
# Authenticable module. Holds common settings for authentication. | |
# | |
# Configuration: | |
# | |
# You can overwrite configuration values by setting in globally in Devise, | |
# using devise method or overwriting the respective instance method. | |
# | |
# authentication_keys: parameters used for authentication. By default [:email]. |
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
define_index do | |
... | |
# it should be this | |
indexes genres(:name) | |
# indexes special_tags(:name), :as => 'special_tags' | |
# and the ugly way to get special_tags working | |
indexes "GROUP_CONCAT(DISTINCT `special_tags_performances`.`name` SEPARATOR ' ')", :as => 'special_tags' | |
set_property :custom_joins => "LEFT OUTER JOIN `taggings` special_tags_performances_join ON (`performances`.`id` = `special_tags_performances_join`.`taggable_id` AND `special_tags_performances_join`.`taggable_type` = 'Performance') LEFT OUTER JOIN `tags` special_tags_performances ON (`special_tags_performances`.`id` = `special_tags_performances_join`.`tag_id`) AND `special_tags_performances`.`context` = 'special_tags'" |
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
# Conditions in has_many :through behave differently for joins and includes | |
# Here is an example using Tagging | |
# The important thing to note from these two models is that the 'context' | |
# of the Tag is kept in the Tag model and not the Tagging | |
# (acts-as-taggable-on keeps it in the Tagging model) | |
class Tag < ActiveRecord::Base | |
has_many :taggings, :dependent => :delete_all |
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 'active_support/core_ext/hash/keys' | |
require 'active_support/core_ext/class/attribute' | |
module ActiveModel | |
class MissingAttributeError < NoMethodError | |
end | |
# == Active Model Attribute Methods | |
# | |
# <tt>ActiveModel::AttributeMethods</tt> provides a way to add prefixes and suffixes | |
# to your methods as well as handling the creation of Active Record like class methods |
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 BetaSignupMailer < ActionMailer::Base | |
default :from => "no-reply@test.com" | |
def send_invite(beta_signup) | |
@beta_signup = beta_signup | |
mail_options = { | |
:to => @beta_signup.email, | |
:bcc => 'api@test.com', | |
:subject => "Welcome to the Beta program" |
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.routes.draw do |map| | |
constraints :protocol => "https://" do | |
get "hi_there", :to => "pages#show", :as => "hi_there" | |
end | |
end | |
>> app.get('http://www.example.com') | |
>> (ignore the output) | |
>> app.hi_there_url | |
=> "http://www.example.com/hi_there" |
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
source :rubygems | |
gemspec |