Skip to content

Instantly share code, notes, and snippets.

View frank184's full-sized avatar
👌
pro g[r]amer

François Bélanger frank184

👌
pro g[r]amer
View GitHub Profile
@frank184
frank184 / application_controller.rb
Created September 21, 2016 23:35
Ruby on Rails - I18n implementation
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
include Devise::Redirects
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
include Locale
end
@frank184
frank184 / application.rb
Last active September 21, 2016 23:38
HasSecureToken extension for shoulda-matchers gem while using has_secure_token gem
# config/application.rb
module YourApp
class Application < Rails::Application
# ...
# Auto load lib folder
config.autoload_paths << Rails.root.join('lib')
end
end
@suweller
suweller / inherit_from_matcher.rb
Created June 26, 2012 13:50
Rspec - Inheritance matcher
RSpec::Matchers.define :inherit_from do |superclass|
match do |klass|
klass.class.ancestors.include? superclass
end
failure_message_for_should do |klass|
"expected #{klass.class.name} to inherit from #{superclass}"
end
failure_message_for_should_not do |klass|