method

_set_wrapper_defaults

Importance_0
v3.2.8 - Show latest stable - 0 notes - Class: ClassMethods
_set_wrapper_defaults(options, model=nil) protected

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File actionpack/lib/action_controller/metal/params_wrapper.rb, line 165
      def _set_wrapper_defaults(options, model=nil)
        options = options.dup

        unless options[:include] || options[:exclude]
          model ||= _default_wrap_model
          role = options.has_key?(:as) ? options[:as] : :default
          if model.respond_to?(:accessible_attributes) && model.accessible_attributes(role).present?
            options[:include] = model.accessible_attributes(role).to_a
          elsif model.respond_to?(:attribute_names) && model.attribute_names.present?
            options[:include] = model.attribute_names
          end
        end

        unless options[:name] || self.anonymous?
          model ||= _default_wrap_model
          options[:name] = model ? model.to_s.demodulize.underscore :
            controller_name.singularize
        end

        options[:include] = Array.wrap(options[:include]).collect(&:to_s) if options[:include]
        options[:exclude] = Array.wrap(options[:exclude]).collect(&:to_s) if options[:exclude]
        options[:format]  = Array.wrap(options[:format])

        self._wrapper_options = options
      end
Register or log in to add new notes.