Use 'Feature's to toggle optional functionality

TODO: Wrap every incomplete project in a feature, and _turn it off_.
This commit is contained in:
James Mason 2017-11-03 20:37:42 -07:00
parent a7fce677fc
commit 0aa782711d
No known key found for this signature in database
GPG key ID: 1B3951886C449023
5 changed files with 19 additions and 3 deletions

View file

@ -185,6 +185,10 @@ gem 'cloudinary'
# for setting app configuration in the environment
gem 'dotenv-rails'
# configurable toggles for functionality
# https://github.com/mgsnova/feature
gem 'feature'
# For countable.js
gem "countable-rails", "~> 0.0.1"

View file

@ -179,6 +179,7 @@ GEM
multipart-post (>= 1.2, < 3)
fastimage (2.0.0)
addressable (~> 2)
feature (1.4.0)
ffi (1.9.18)
font-awesome-rails (4.7.0.2)
railties (>= 3.2, < 5.2)
@ -591,6 +592,7 @@ DEPENDENCIES
dotenv-rails
factory_girl_rails
faker
feature
font-awesome-rails
formtastic (~> 3.1.1)
formtastic-bootstrap

View file

@ -45,11 +45,10 @@ class RegistrationsController < Devise::RegistrationsController
end
def check_captcha
unless verify_recaptcha
unless Feature.inactive?(:recaptcha) || verify_recaptcha
self.resource = resource_class.new sign_up_params
resource.validate # Look for any other validation errors besides Recaptcha
respond_with_navigational(resource) { render :new }
end
end
end

View file

@ -12,6 +12,7 @@
= f.input :name, input_html: { required: true }, hint: 'This is your real name'
= f.input :password, input_html: { required: true }
= f.input :password_confirmation, input_html: { required: true }
- Feature.with(:recaptcha) do
= recaptcha_tags
%p.text-right
= f.action :submit, as: :button, label: 'Sign Up', button_html: { class: 'btn btn-success' }

View file

@ -0,0 +1,10 @@
require 'feature'
repo = Feature::Repository::SimpleRepository.new
# configure features here
unless(ENV['RECAPTCHA_SITE_KEY'].blank? || ENV['RECAPTCHA_SECRET_KEY'].blank?)
repo.add_active_feature :recaptcha
end
Feature.set_repository repo