Sha256: 5e1858e82664e9025e1746c4212b3018d6fb1b982ed56558b11181b3203135f3
Contents?: true
Size: 1.37 KB
Versions: 10
Compression:
Stored size: 1.37 KB
Contents
module Locomotive module CustomFields class SelectOptionsController < BaseController before_filter :load_content_type before_filter :load_custom_field def edit respond_with @custom_field end def update @options = service.update_select_options(options_params) respond_with @custom_field, location: -> { last_saved_location!(default_back_location) } end def new_option if params[:select_option].present? option = @custom_field.select_options.build(name: option_name_param) render partial: 'option', locals: { select_option: option } else head :unprocessable_entity end end private def load_content_type @content_type ||= current_site.content_types.where(slug: params[:slug]).first end def load_custom_field @custom_field = @content_type.entries_custom_fields.where(name: params[:name]).first end def service @service ||= Locomotive::CustomFieldService.new(@custom_field) end def options_params params.require(:select_options).map { |p| p.permit(:_id, :name, :_destroy) } end def option_name_param params.require(:select_option) end def default_back_location content_entries_path(current_site, @content_type.slug) end end end end
Version data entries
10 entries across 10 versions & 1 rubygems