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
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| |
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 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 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 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 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 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 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 'zeus/rails' | |
class CustomPlan < Zeus::Rails | |
def spec(argv=ARGV) | |
# disable autorun in case the user left it in spec_helper.rb | |
RSpec::Core::Runner.disable_autorun! | |
exit RSpec::Core::Runner.run(argv) | |
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
def hstore_get(field_name) | |
method(field_name).call | |
end | |
def hstore_set(field_name,value) | |
method("#{field_name}=").call(value) | |
end | |
def hstore_accessor(field_name,name) | |
define_method(name) do | |
hstore = hstore_get(field_name) |
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
# Ignore application configuration | |
/config/application.yml | |
/config/fog_credentials.yml | |
# Ignore the default SQLite database. | |
/db/*.sqlite3 | |
/db/*.sqlite3-journal | |
# Ignore all logfiles and tempfiles and local system/bin files | |
/log |
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 Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
OlderNewer