adding tags to page models
git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@33 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7master
parent
f3940be586
commit
07aa98e94f
|
@ -12,6 +12,7 @@
|
||||||
#
|
#
|
||||||
class Page < ActiveRecord::Base
|
class Page < ActiveRecord::Base
|
||||||
acts_as_versioned
|
acts_as_versioned
|
||||||
|
acts_as_taggable
|
||||||
|
|
||||||
belongs_to :owner, :polymorphic => true
|
belongs_to :owner, :polymorphic => true
|
||||||
validates_presence_of :title
|
validates_presence_of :title
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
class Tag < ActiveRecord::Base
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
<%= @page.html %>
|
<%= @page.html %>
|
||||||
</div>
|
</div>
|
||||||
<ul class="meta">
|
<ul class="meta">
|
||||||
<li>Add Tags here</li>
|
<li>Tags: <%= @page.tag_names.join(' ') -%></li>
|
||||||
<li>Version: <%= @page.version -%></li>
|
<li>Version: <%= @page.version -%></li>
|
||||||
<% @page.owner.page_attributes.each do |x| -%>
|
<% @page.owner.page_attributes.each do |x| -%>
|
||||||
<li><%= x -%></li>
|
<li><%= x -%></li>
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
<p>
|
<p>
|
||||||
<label for="page_redcloth">Description</label> <%= text_area 'page', 'redcloth' %>
|
<label for="page_redcloth">Description</label> <%= text_area 'page', 'redcloth' %>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="page_tag_names">Tags</label> <%= text_field 'page', 'tag_names' %>
|
||||||
|
</p>
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
class Tags < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
create_table :tags do |t|
|
||||||
|
t.column :name, :string
|
||||||
|
end
|
||||||
|
create_table :tags_pages, :id => false do |t|
|
||||||
|
t.column :tag_id, :integer
|
||||||
|
t.column :page_id, :integer
|
||||||
|
end
|
||||||
|
add_index :tags, :name
|
||||||
|
add_index :tags_pages, [ :tag_id, :page_id ]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
drop_table :tags
|
||||||
|
drop_table :tags_pages
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||||
|
one:
|
||||||
|
id: 1
|
||||||
|
two:
|
||||||
|
id: 2
|
|
@ -0,0 +1,10 @@
|
||||||
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
|
|
||||||
|
class TagTest < Test::Unit::TestCase
|
||||||
|
fixtures :tags
|
||||||
|
|
||||||
|
# Replace this with your real tests.
|
||||||
|
def test_truth
|
||||||
|
assert true
|
||||||
|
end
|
||||||
|
end
|
Reference in New Issue