From 4f09a5a7a5b6ced4d663ffa95d43b918afedafd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Sat, 12 Aug 2017 04:10:45 +0200 Subject: [PATCH] Add 'Post.permitted_create_params' to allow plugins to add new params when creating a post --- app/controllers/posts_controller.rb | 4 ++++ app/models/post.rb | 3 +++ 2 files changed, 7 insertions(+) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 1794ddded0b..ca69ac2f14d 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -561,6 +561,10 @@ class PostsController < ApplicationController :visible ] + if Post.permitted_create_params.present? + permitted.concat(Post.permitted_create_params.to_a) + end + # param munging for WordPress params[:auto_track] = !(params[:auto_track].to_s == "false") if params[:auto_track] params[:visible] = (params[:unlist_topic].to_s == "false") if params[:unlist_topic] diff --git a/app/models/post.rb b/app/models/post.rb index e967f46bd43..16e56e338ce 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -17,6 +17,9 @@ class Post < ActiveRecord::Base include HasCustomFields include LimitedEdit + cattr_accessor :permitted_create_params + self.permitted_create_params = Set.new + # increase this number to force a system wide post rebake BAKED_VERSION = 1