When trying to accept a tag_list through a JSON API like so:
POST /articles/
{
title: "My Article Title",
body: "bla bla bla...",
tag_list: "awesome, cool"
}
Rails doesn't wrap the tag_list attribute in params[:article] like the other two attributes are. This is because ParamsWrapper uses Article.attribute_names which returns only ["id", "title", "body"]. This forces one to specify the wrap_parameters method like this:
class ArticlesController < ApplicationController
wrap_parameters :article, include: Article.attribute_names + [:tag_list]
end
# must do above, otherwise cant use
shift = Shift.new(shift_params[:article])
# and must use instead `
shift = Shift.new(shift_params[:article])
shift.tag_list = params[:tag_list]
When trying to accept a tag_list through a JSON API like so:
Rails doesn't wrap the tag_list attribute in params[:article] like the other two attributes are. This is because
ParamsWrapper
usesArticle.attribute_names
which returns only ["id", "title", "body"]. This forces one to specify the wrap_parameters method like this:Is there any way we can fix this?