public
Description: A small simple blogger for those that only need the basic blogging functionality.
Homepage: http://www.nu2rails.com
Clone URL: git://github.com/nu2rails/rblog.git
Search Repo:
Click here to lend your support to: rblog and make a donation at www.pledgie.com !
Added basic tagging functionality
Mitchell Blankenship (author)
Sat Jul 05 21:14:13 -0700 2008
commit  bd1154c951d5bd03deecdba2c42f38b737e993be
tree    5b826058f37ebda824aa12dc9666db03811e10e0
parent  8995e2b51cfcc00e74e2ef55928e692d58245e5c
...
1
2
3
 
 
 
4
5
6
...
13
14
15
16
 
17
18
19
...
1
2
3
4
5
6
7
8
9
...
16
17
18
 
19
20
21
22
0
@@ -1,6 +1,9 @@
0
 class Post < ActiveRecord::Base
0
   # Add association for comments
0
   has_many :comments, :as => :commentary, :dependent => :destroy
0
+
0
+ # Make posts taggable
0
+ acts_as_taggable
0
 
0
   # Use a self referential association for parent and child posts.
0
   has_one :child, :class_name => "Post", :foreign_key => 'parent_id'
0
@@ -13,7 +16,7 @@ class Post < ActiveRecord::Base
0
   before_save :make_description, :set_author
0
 
0
   # Let's make sure some necassary fields are filled out before we go too far.
0
- validates_presence_of :title, :author, :body
0
+ validates_presence_of :title, :body
0
 
0
   # Find the newest five posts for the recent posts sidebar
0
   def self.recent
...
13
14
15
 
 
 
 
 
16
17
18
...
13
14
15
16
17
18
19
20
21
22
23
0
@@ -13,6 +13,11 @@
0
   <%= fckeditor_textarea("post", "body", :toolbarSet => 'Simple', :width => '100%', :height => '400px') %>
0
 </div>
0
 
0
+<h3 id="tag_list_heading">Tags:</h3>
0
+<div id="tag_list_field">
0
+ <%= f.text_field :tag_list %>
0
+</div>
0
+
0
 <h3 id="parent_heading"><%= link_to_remote "Parent:", :url => '#', :complete => visual_effect(:toggle_blind, "parent_field", :duration => 1) %></h3>
0
 <div id="parent_field" style="display:none">
0
   <%= f.collection_select :parent_id, Post.find(:all), :id, :title, :include_blank => true %>
...
7
8
9
10
11
12
 
 
13
14
 
 
15
 
 
 
 
 
 
16
17
 
18
19
...
7
8
9
 
 
 
10
11
12
 
13
14
15
16
17
18
19
20
21
22
 
23
24
25
0
@@ -7,13 +7,19 @@
0
     <% if post.child %>
0
       <span id="parent_message">This is a continued with <%= link_to 'this post', post_path(post.child.id) %></span><br />  
0
     <% end %>
0
- <% if @current_action == 'index' %>
0
- <%= post.description %>
0
- <p class="comments align-right clear"><%= link_to "Read More", post %> | <%= pluralize(post.comments.count, "Comment") %></p>
0
+ <% if @current_action == 'show' && @current_controller == 'posts' %>
0
+ <%= post.body %>
0
     <% else %>
0
- <%= post.body %>
0
+ <%= post.description %>
0
+ <p class="comments align-right clear"><%= link_to "Read More", post %> | <%= pluralize(post.comments.count, "Comment") %></p>
0
     <% end %>
0
+ <p>
0
+ <b>Taged:</b><br />
0
+ <% for tag in post.tags %>
0
+ <%= link_to tag.name, tag %>
0
+ <% end %>
0
+ </p>
0
     <% if admin? %>
0
- <p class="comments align-right clear"><%= link_to "Edit", edit_object_url(post) %> | <%= link_to "Delete", object_url(post), :confirm => "Are you sure you want to delete #{post.title}", :method => "delete" %></p>
0
+ <p class="comments align-right clear"><%= link_to "Edit", edit_post_url(post) %> | <%= link_to "Delete", post_url(post), :confirm => "Are you sure you want to delete #{post.title}", :method => "delete" %></p>
0
     <% end %>
0
 </div>
...
1
 
2
3
4
...
1
2
3
4
5
0
@@ -1,4 +1,5 @@
0
 ActionController::Routing::Routes.draw do |map|
0
+ map.resources :tags
0
   map.resources :links
0
 
0
   map.root :controller => 'posts'
...
9
10
11
12
 
13
14
15
...
42
43
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
...
9
10
11
 
12
13
14
15
...
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
0
@@ -9,7 +9,7 @@
0
 #
0
 # It's strongly recommended to check this file into your version control system.
0
 
0
-ActiveRecord::Schema.define(:version => 3) do
0
+ActiveRecord::Schema.define(:version => 20080706033841) do
0
 
0
   create_table "comments", :force => true do |t|
0
     t.integer "commentary_id"
0
@@ -42,4 +42,18 @@ ActiveRecord::Schema.define(:version => 3) do
0
     t.datetime "updated_at"
0
   end
0
 
0
+ create_table "taggings", :force => true do |t|
0
+ t.integer "tag_id"
0
+ t.integer "taggable_id"
0
+ t.string "taggable_type"
0
+ t.datetime "created_at"
0
+ end
0
+
0
+ add_index "taggings", ["taggable_id", "taggable_type"], :name => "index_taggings_on_taggable_id_and_taggable_type"
0
+ add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
0
+
0
+ create_table "tags", :force => true do |t|
0
+ t.string "name"
0
+ end
0
+
0
 end

Comments

    No one has commented yet.