mbleigh / acts-as-taggable-on

A tagging plugin for Rails applications that allows for custom tagging along dynamic contexts.
http://mbleigh.lighthouseapp.com/projects/10116-acts-as-taggable-on
MIT License
4.97k stars 1.19k forks source link

Tag List parameter not being wrapped by ParamsWrapper #710

Open yjukaku opened 8 years ago

yjukaku commented 8 years ago

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]

Is there any way we can fix this?

ghost commented 7 years ago

Any news?

I'm stucked in a similar problem: https://github.com/mbleigh/acts-as-taggable-on/issues/833