I am trying to create a large number of tags inside my database, does anyone know how to do this with gem acts-as-taggable-on
Product table:
create_table :products do |t|
t.string :name
t.date :date
t.decimal :price, :default => 0, :precision => 10, :scale => 2
t.integer :user_id
end
and the field is a virtual column created by migration : :tag_listActsAsTaggableOn
class ActsAsTaggableOnMigration < ActiveRecord::Migration
def self.up
create_table :tags do |t|
t.string :name
end
create_table :taggings do |t|
t.references :tag
t.references :taggable, :polymorphic => true
t.references :tagger, :polymorphic => true
t.string :context
t.datetime :created_at
end
add_index :taggings, :tag_id
add_index :taggings, [:taggable_id, :taggable_type, :context]
end
def self.down
drop_table :taggings
drop_table :tags
end
end
This is my field :tag_listin my products /form.html.erb
<div class="field">
<%= f.label :tag_list %>:
<%= f.text_field :tag_list %>
</div>
I tried to do something like this ....
Product.create([
{:tag_list => 'Foods'},
{:tag_list => 'Electronics'},
{:tag_list => 'Pizza'},
{:tag_list => 'Groceries'},
{:tag_list => 'Walmart'},
{:tag_list => 'Apples'},
{:tag_list => 'Oranges'} ])
But my lack of RoR skill tells me that this is the wrong way, and that I need help, any suggestions?