Class: CompletionKit::CriteriaController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- CompletionKit::CriteriaController
- Defined in:
- app/controllers/completion_kit/criteria_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/criteria_controller.rb', line 21 def create @criteria = Criteria.new(criteria_params.except(:metric_ids)) @metrics = Metric.order(:name) if @criteria.save replace_metric_memberships redirect_to criterion_path(@criteria), notice: "Criteria was successfully created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
44 45 46 47 |
# File 'app/controllers/completion_kit/criteria_controller.rb', line 44 def destroy @criteria.destroy redirect_to criteria_path, notice: "Criteria was successfully destroyed." end |
#edit ⇒ Object
17 18 19 |
# File 'app/controllers/completion_kit/criteria_controller.rb', line 17 def edit @metrics = Metric.order(:name) end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/completion_kit/criteria_controller.rb', line 5 def index @criterias = Criteria.includes(:metrics).order(:name) end |
#new ⇒ Object
12 13 14 15 |
# File 'app/controllers/completion_kit/criteria_controller.rb', line 12 def new @criteria = Criteria.new @metrics = Metric.order(:name) end |
#show ⇒ Object
9 10 |
# File 'app/controllers/completion_kit/criteria_controller.rb', line 9 def show end |
#update ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/completion_kit/criteria_controller.rb', line 33 def update @metrics = Metric.order(:name) if @criteria.update(criteria_params.except(:metric_ids)) replace_metric_memberships redirect_to criterion_path(@criteria), notice: "Criteria was successfully updated." else render :edit, status: :unprocessable_entity end end |