Sha256: 36d708bee59036e7b4e624fe1f3b14420e03ffeb6c5db7f9289b231017028d4a
Contents?: true
Size: 766 Bytes
Versions: 7
Compression:
Stored size: 766 Bytes
Contents
# frozen_string_literal: true module Cookbook # Concern to allow strong parameters when using accepts_nested_attributes_for to edit Cookbook Uses module Params extend ActiveSupport::Concern included do # rescue_from Pundit::NotAuthorizedError, with: :authorization_error # include Pundit end def cookbook_params(model_name) model = model_name.constantize attributes = {} model.used_in.each do |table_sym| singular = table_sym.to_s.singularize attribute_sym = "#{singular}_uses_attributes".to_sym attributes[attribute_sym] = %i[ id _destroy use_of_type use_of_id quantity_minimum quantity_maximum unit preparation note sort ] end attributes end end end
Version data entries
7 entries across 7 versions & 1 rubygems