Class: FeaturesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/features_controller.rb', line 42

def create
  @feature = @featureable.features.build(feature_params)

  respond_to do |format|
    if @feature.save
      format.html { redirect_to @featureable, notice: 'Feature was successfully created.' }
      format.json { render json: @feature, status: :created, location: @feature }
    else
      format.html { redirect_to @featureable, alert: @feature.errors.full_messages.join(',') }
      format.json { render json: @feature.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject



70
71
72
73
74
75
76
77
78
# File 'app/controllers/features_controller.rb', line 70

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

  respond_to do |format|
    format.html { redirect_to @featureable, notice: 'Feature was successfully removed.' }
    format.json { head :no_content }
  end
end

#editObject



33
34
35
36
37
38
39
40
# File 'app/controllers/features_controller.rb', line 33

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

  respond_to do |format|
    format.html
    format.json { render json: @feature }
  end
end

#indexObject



6
7
8
9
10
11
12
13
# File 'app/controllers/features_controller.rb', line 6

def index
  @features = Feature.all

  respond_to do |format|
    format.html
    format.json { render json: @features }
  end
end

#newObject



24
25
26
27
28
29
30
31
# File 'app/controllers/features_controller.rb', line 24

def new
  @feature = @featureable.features.build

  respond_to do |format|
    format.html
    format.json { render json: @feature }
  end
end

#showObject



15
16
17
18
19
20
21
22
# File 'app/controllers/features_controller.rb', line 15

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

  respond_to do |format|
    format.html
    format.json { render json: @feature }
  end
end

#updateObject



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/features_controller.rb', line 56

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

  respond_to do |format|
    if @feature.update(feature_params)
      format.html { redirect_to @featureable, notice: 'Feature was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { redirect_to @featureable, alert: @feature.errors.full_messages.join(',') }
      format.json { render json: @feature.errors, status: :unprocessable_entity }
    end
  end
end