Class: CompletionKit::MetricGroupsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- CompletionKit::MetricGroupsController
- Defined in:
- app/controllers/completion_kit/metric_groups_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/completion_kit/metric_groups_controller.rb', line 21 def create @metric_group = MetricGroup.new(metric_group_params.except(:metric_ids)) @metrics = Metric.order(:name) if @metric_group.save replace_metric_memberships redirect_to metric_group_path(@metric_group), notice: "Metric group was successfully created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
44 45 46 47 |
# File 'app/controllers/completion_kit/metric_groups_controller.rb', line 44 def destroy @metric_group.destroy redirect_to metric_groups_path, notice: "Metric group was successfully destroyed." end |
#edit ⇒ Object
17 18 19 |
# File 'app/controllers/completion_kit/metric_groups_controller.rb', line 17 def edit @metrics = Metric.order(:name) end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/completion_kit/metric_groups_controller.rb', line 5 def index @metric_groups = MetricGroup.includes(:metrics).order(:name) end |
#new ⇒ Object
12 13 14 15 |
# File 'app/controllers/completion_kit/metric_groups_controller.rb', line 12 def new @metric_group = MetricGroup.new @metrics = Metric.order(:name) end |
#show ⇒ Object
9 10 |
# File 'app/controllers/completion_kit/metric_groups_controller.rb', line 9 def show end |
#update ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/completion_kit/metric_groups_controller.rb', line 33 def update @metrics = Metric.order(:name) if @metric_group.update(metric_group_params.except(:metric_ids)) replace_metric_memberships redirect_to metric_group_path(@metric_group), notice: "Metric group was successfully updated." else render :edit, status: :unprocessable_entity end end |