Reputation: 2344
I'm trying to implement the gem mongoid_taggable - a link - which provides a simple tag system to an app with a mongoDB.
I'm implementing it the way it's adviced on github, but the tags array I get in my mongoDB is empty!
Hope you can put me on the right track:
Model -
class Flow
include Mongoid::Document
include Mongoid::Taggable
attr_accessible :shot, :image, :remote_image_url
mount_uploader :image, UserUploader
belongs_to :user
field :shot, :type => String
field :remote_image_url, :type => String
end
View -
<%= form_for @flow, :html => {:multipart => true}, :html => { :class => 'form-horizontal' } do |f| %>
<fieldset>
<legend><%= controller.action_name.capitalize %> /Form</legend>
<p>
<%= f.label :image %>
<%= f.file_field :image %>
<p/>
<p>
<%= f.label :tags %><br />
<%= f.text_field :tags %>
</p>
<div class="form-actions">
<%= f.submit nil, :class => 'btn btn-primary' %>
<%= link_to 'Cancel', users_path, :class => 'btn' %>
</div>
</fieldset>
<% end %>
Database output -
{ "_id" : ObjectId("4f6a13220f15ed07fb000006"), "tags_array" : [ ], "image_filename" : "_MG_2221.jpg" }
Upvotes: 0
Views: 143
Reputation: 46914
It's because you don't allow mass_assignement on tags.
You have :
attr_accessible :shot, :image, :remote_image_url
But the tags is need to be assign. So do :
attr_accessible :shot, :image, :remote_image_url, :tags
Upvotes: 1