Sha256: 182b24de501d8a6fe3a827b93f9328cb0f6fd1e679acd9c10bbdc85fc58e6d03
Contents?: true
Size: 917 Bytes
Versions: 1
Compression:
Stored size: 917 Bytes
Contents
# frozen_string_literal: true class Fields::ChoicesController < Fields::ApplicationController before_action :require_attach_choices! before_action :set_choice, only: %i[edit update destroy] def new @choice = @field.choices.build end def create @choice = @field.choices.build choice_params if @choice.save redirect_to field_choices_url(@field) else render :new end end def edit; end def update if @choice.update choice_params redirect_to field_choices_url(@field) else render :edit end end def destroy @choice.destroy redirect_to field_choices_url(@field) end private def require_attach_choices! unless @field.attached_choices? redirect_to fields_url end end def choice_params params.require(:choice).permit(:label) end def set_choice @choice = @field.choices.find(params[:id]) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
script_core-0.1.0 | spec/dummy/app/controllers/fields/choices_controller.rb |