Use 'Feature's to toggle optional functionality
TODO: Wrap every incomplete project in a feature, and _turn it off_.
This commit is contained in:
parent
a7fce677fc
commit
0aa782711d
5 changed files with 19 additions and 3 deletions
4
Gemfile
4
Gemfile
|
|
@ -185,6 +185,10 @@ gem 'cloudinary'
|
||||||
# for setting app configuration in the environment
|
# for setting app configuration in the environment
|
||||||
gem 'dotenv-rails'
|
gem 'dotenv-rails'
|
||||||
|
|
||||||
|
# configurable toggles for functionality
|
||||||
|
# https://github.com/mgsnova/feature
|
||||||
|
gem 'feature'
|
||||||
|
|
||||||
# For countable.js
|
# For countable.js
|
||||||
gem "countable-rails", "~> 0.0.1"
|
gem "countable-rails", "~> 0.0.1"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,7 @@ GEM
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
fastimage (2.0.0)
|
fastimage (2.0.0)
|
||||||
addressable (~> 2)
|
addressable (~> 2)
|
||||||
|
feature (1.4.0)
|
||||||
ffi (1.9.18)
|
ffi (1.9.18)
|
||||||
font-awesome-rails (4.7.0.2)
|
font-awesome-rails (4.7.0.2)
|
||||||
railties (>= 3.2, < 5.2)
|
railties (>= 3.2, < 5.2)
|
||||||
|
|
@ -591,6 +592,7 @@ DEPENDENCIES
|
||||||
dotenv-rails
|
dotenv-rails
|
||||||
factory_girl_rails
|
factory_girl_rails
|
||||||
faker
|
faker
|
||||||
|
feature
|
||||||
font-awesome-rails
|
font-awesome-rails
|
||||||
formtastic (~> 3.1.1)
|
formtastic (~> 3.1.1)
|
||||||
formtastic-bootstrap
|
formtastic-bootstrap
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,10 @@ class RegistrationsController < Devise::RegistrationsController
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_captcha
|
def check_captcha
|
||||||
unless verify_recaptcha
|
unless Feature.inactive?(:recaptcha) || verify_recaptcha
|
||||||
self.resource = resource_class.new sign_up_params
|
self.resource = resource_class.new sign_up_params
|
||||||
resource.validate # Look for any other validation errors besides Recaptcha
|
resource.validate # Look for any other validation errors besides Recaptcha
|
||||||
respond_with_navigational(resource) { render :new }
|
respond_with_navigational(resource) { render :new }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@
|
||||||
= f.input :name, input_html: { required: true }, hint: 'This is your real name'
|
= f.input :name, input_html: { required: true }, hint: 'This is your real name'
|
||||||
= f.input :password, input_html: { required: true }
|
= f.input :password, input_html: { required: true }
|
||||||
= f.input :password_confirmation, input_html: { required: true }
|
= f.input :password_confirmation, input_html: { required: true }
|
||||||
= recaptcha_tags
|
- Feature.with(:recaptcha) do
|
||||||
|
= recaptcha_tags
|
||||||
%p.text-right
|
%p.text-right
|
||||||
= f.action :submit, as: :button, label: 'Sign Up', button_html: { class: 'btn btn-success' }
|
= f.action :submit, as: :button, label: 'Sign Up', button_html: { class: 'btn btn-success' }
|
||||||
|
|
||||||
|
|
|
||||||
10
config/initializers/feature.rb
Normal file
10
config/initializers/feature.rb
Normal 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue