Acts-as-Taggable in Rails 4 won't work properly

时间:2015-07-28 15:41:12

标签: ruby-on-rails acts-as-taggable-on

I am using the acts-as-taggable gem in a Rails 4 app with an angular frontend. If I use the console it works fine. I have done all the obvious things and I can get it to work by adding this to the create controller:

if params[:tag_list]
  droplet.tag_list.add(params[:tag_list], parse: true)
end

The problem is that it should be doing this anyway. Does anyone have any insight as to why it is simply not firing the tag_list.add method automatically? I am uncomfortable using this hack to get it to work.

And yes, I have added :tag_list to the strong parameters.

Update: The form html

<form ng-submit="createNewDropletForm.$valid && createNewDroplet()" name="createNewDropletForm" novalidate>
  <div class="form-group">
    <label for="name">Title:</label>
    <input ng-keyup="keyup()" ng-model="drop.name" ng-model-options="{ debounce: 500 }" type="text" class="form-control" placeholder="Add Droplet Title Here" required>
  </div>
  <div class="form-group">
    <label for="description">Description:</label>
    <textarea class="form-control" rows="4" ng-model="drop.description" placeholder="Add helpful description of what this droplet tests." required></textarea>
  </div>
  <div class="form-group">
    <label for="tags">Tags:</label>
    <input class="form-control" ng-model="drop.tag_list" placeholder="add tags separated by commas">
  </div>
  <button type="submit" class="btn btn-default">Next</button>
</form>

0 个答案:

没有答案