Sha256: 959642b800febb3d88ca6578402dc361d01dbca97e058d17e366c5613dc1ef55

Contents?: true

Size: 574 Bytes

Versions: 7

Compression:

Stored size: 574 Bytes

Contents

# frozen_string_literal: true
module Thredded
  # @api private
  module NewPrivateTopicParams
    protected

    def new_private_topic_params
      params
        .require(:private_topic)
        .permit(:title, :content, :user_ids, user_ids: [])
        .merge(
          user: thredded_current_user,
          ip: request.remote_ip
        ).tap { |p| adapt_user_ids! p }
    end

    private

    # select2 returns a string of IDs joined with commas.
    def adapt_user_ids!(p)
      p[:user_ids] = p[:user_ids].split(',') if p[:user_ids].is_a?(String)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
thredded-0.12.1 app/controllers/concerns/thredded/new_private_topic_params.rb
thredded-0.12.0 app/controllers/concerns/thredded/new_private_topic_params.rb
thredded-0.11.1 app/controllers/concerns/thredded/new_private_topic_params.rb
thredded-0.11.0 app/controllers/concerns/thredded/new_private_topic_params.rb
thredded-0.10.1 app/controllers/concerns/thredded/new_private_topic_params.rb
thredded-0.10.0 app/controllers/concerns/thredded/new_private_topic_params.rb
thredded-0.9.4 app/controllers/concerns/thredded/new_private_topic_params.rb