I have a model named "seo"
class Seo < ApplicationRecord
belongs_to :seoable, polymorphic: true
# more code
end
Many models in my application has_one seo. For example
class Post < ApplicationRecord
has_one :seo, as: :seoable
accepts_nested_attributes_for :seo, dependent: :destroy
# more code
end
My question is, what is the best way to keep params in my controllers dry. For example I have the following code in my posts_controller
def post_params
params.require(:post).permit(seo_attributes: [:id, :title, :meta_description, :etc])
end
Every model will repeat the above. How do I keep this DRY?