Class: Arturo::FeaturesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Arturo::FeaturesController
- Includes:
- FeatureManagement, FeatureParamsSupport
- Defined in:
- app/controllers/arturo/features_controller.rb
Overview
Handles all Feature actions. Clients of the Arturo engine should redefine Arturo::FeaturesController#may_manage_features? to return true only for users who are permitted to manage features.
Instance Method Summary collapse
- #arturo_engine ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #update_all ⇒ Object
Methods included from FeatureManagement
Instance Method Details
#arturo_engine ⇒ Object
22 23 24 |
# File 'app/controllers/arturo/features_controller.rb', line 22 def arturo_engine self end |
#create ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/arturo/features_controller.rb', line 63 def create @feature = Arturo::Feature.new(feature_params) if @feature.save flash[:notice] = t('arturo.features.flash.created', :name => @feature.to_s) redirect_to arturo_engine.features_path else flash[:alert] = t('arturo.features.flash.error_creating', :name => @feature.to_s) render :action => 'new' end end |
#destroy ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'app/controllers/arturo/features_controller.rb', line 88 def destroy if @feature.destroy flash[:notice] = t('arturo.features.flash.removed', :name => @feature.to_s) else flash[:alert] = t('arturo.features.flash.error_removing', :name => @feature.to_s) end redirect_to arturo_engine.features_path end |
#edit ⇒ Object
74 75 76 |
# File 'app/controllers/arturo/features_controller.rb', line 74 def edit respond_with @feature end |
#index ⇒ Object
28 29 30 31 |
# File 'app/controllers/arturo/features_controller.rb', line 28 def index @features = Arturo::Feature.all respond_with @features end |
#new ⇒ Object
58 59 60 61 |
# File 'app/controllers/arturo/features_controller.rb', line 58 def new @feature = Arturo::Feature.new(feature_params) respond_with @feature end |
#show ⇒ Object
54 55 56 |
# File 'app/controllers/arturo/features_controller.rb', line 54 def show respond_with @feature end |
#update ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'app/controllers/arturo/features_controller.rb', line 78 def update if @feature.update_attributes(feature_params) flash[:notice] = t('arturo.features.flash.updated', :name => @feature.to_s) redirect_to arturo_engine.feature_path(@feature) else flash[:alert] = t('arturo.features.flash.error_updating', :name => @feature.to_s) render :action => 'edit' end end |
#update_all ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/arturo/features_controller.rb', line 33 def update_all updated_count = 0 errors = [] features_params.each do |id, attributes| feature = Arturo::Feature.find_by_id(id) if feature.blank? errors << t('arturo.features.flash.no_such_feature', :id => id) elsif feature.update_attributes(attributes) updated_count += 1 else errors << t('arturo.features.flash.error_updating', :id => id, :errors => feature.errors..to_sentence) end end if errors.any? flash[:error] = errors else flash[:success] = t('arturo.features.flash.updated_many', :count => updated_count) end redirect_to arturo_engine.features_path end |