This file contains hidden or 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 | |
after_commit :update_external_email, :if => :email_previously_changed? | |
private | |
def update_external_email | |
# do whatever you need to do | |
end |
This file contains hidden or 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 gravatar_for email, options = {} | |
options = {:alt => 'avatar', :class => 'avatar', :size => 80}.merge! options | |
id = Digest::MD5::hexdigest email.strip.downcase | |
url = 'http://www.gravatar.com/avatar/' + id + '.jpg?s=' + options[:size].to_s | |
options.delete :size | |
image_tag url, options | |
end | |
# Using identicons etc through gravatar (see http://en.gravatar.com/site/implement/images/) | |
id = Digest::MD5::hexdigest email.strip.downcase |
This file contains hidden or 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 SetupHstore < ActiveRecord::Migration | |
def self.up | |
enable_extension "hstore" | |
end | |
def self.down | |
disable_extension "hstore" | |
end | |
end |
This file contains hidden or 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 'spec_helper' | |
feature "Login" do | |
scenario "remembered user" do | |
password = "12345678" | |
user = create(:user, password: password) | |
access_protected_page_should_ask_to_login | |
current_path.should eq login_path |
This file contains hidden or 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 RegistrationsController < Devise::RegistrationsController | |
def resource_params | |
permit_keys = [ :password, :password_confirmation ] + resource_class.authentication_keys | |
params.require(resource_name).permit( *permit_keys ) | |
end | |
end |
This file contains hidden or 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
config.use_transactional_fixtures = false | |
config.before(:suite) do | |
# Do truncation once per suite to vacuum for Postgres | |
DatabaseCleaner.clean_with :truncation | |
# Normally do transactions-based cleanup | |
DatabaseCleaner.strategy = :transaction | |
end | |
config.around(:each) do |spec| |
NewerOlder