Class: FeatureFlagsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- FeatureFlagsController
- Defined in:
- app/controllers/feature_flags_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #disable_all ⇒ Object
- #edit ⇒ Object
- #enable_all ⇒ Object
- #index ⇒ Object
- #load_features ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/feature_flags_controller.rb', line 16 def create @feature = Feature.new(params[:feature]) respond_to do |format| if @feature.save flash[:notice] = "#{@feature.name} feature successfully created" format.html{ redirect_to feature_flags_url } else flash[:error] = "#{@feature.name} feature could not be created" format.html{ render :new } end end end |
#destroy ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/feature_flags_controller.rb', line 68 def destroy feature = Feature.find(params[:id]) respond_to do |format| if feature.destroy flash[:notice] = "Feature successfully removed" format.html{ redirect_to feature_flags_url } format.js{ render :json => {:status => true, :message => flash[:notice]} } else flash[:error] = "This feature could not be removed" format.html{ redirect_to feature_flags_url } format.js{ render :json => {:status => false, :message => flash[:error]} } end end end |
#disable_all ⇒ Object
37 38 39 |
# File 'app/controllers/feature_flags_controller.rb', line 37 def disable_all FeatureFlags.disable_all end |
#edit ⇒ Object
12 13 14 |
# File 'app/controllers/feature_flags_controller.rb', line 12 def edit @feature = Feature.find(params[:id]) end |
#enable_all ⇒ Object
33 34 35 |
# File 'app/controllers/feature_flags_controller.rb', line 33 def enable_all FeatureFlags.enable_all end |
#index ⇒ Object
5 6 |
# File 'app/controllers/feature_flags_controller.rb', line 5 def index end |
#load_features ⇒ Object
93 94 95 |
# File 'app/controllers/feature_flags_controller.rb', line 93 def load_features @features = Feature.all end |
#new ⇒ Object
8 9 10 |
# File 'app/controllers/feature_flags_controller.rb', line 8 def new @feature = Feature.new end |
#update ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/feature_flags_controller.rb', line 41 def update feature = Feature.find(params[:id]) enabled_all = params[:enable_all].present? ? enable_all : false disabled_all = params[:disable_all].present? ? disable_all : false respond_to do |format| if enabled_all || disabled_all || feature.update_attributes(params[:feature]) flash[:notice] = "#{feature.name} feature successfully updated" format.html{ redirect_to feature_flags_url } format.js{ render :json => {:status => true, :message => flash[:notice]} } else flash[:error] = "#{feature.name} feature could not be updated" format.html{ redirect_to feature_flags_url } format.js{ render :json => {:status => false, :message => flash[:error]} } end end end |