Class: FeatureFlagsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/feature_flags_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/feature_flags_controller.rb', line 16

def create
  @features = Feature.all
  @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

#destroyObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'app/controllers/feature_flags_controller.rb', line 60

def destroy
  @features = Feature.all   
  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

#editObject



12
13
14
# File 'app/controllers/feature_flags_controller.rb', line 12

def edit
  @feature = Feature.find(params[:id])
end

#indexObject



4
5
6
# File 'app/controllers/feature_flags_controller.rb', line 4

def index
  @features = Feature.all   
end

#newObject



8
9
10
# File 'app/controllers/feature_flags_controller.rb', line 8

def new
  @feature = Feature.new
end

#updateObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/feature_flags_controller.rb', line 34

def update 
  @features = Feature.all   
  feature = Feature.find(params[:id])

  respond_to do |format|
    if 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