New Getting started guide wont have tags

This commit is contained in:
Oscar Del Ben 2012-04-20 10:47:38 +02:00
parent f6d5036dd6
commit dbb4c4ddb6
6 changed files with 1 additions and 36 deletions

View File

@ -1,5 +1,2 @@
module PostsHelper
def join_tags(post)
post.tags.map { |t| t.name }.join(", ")
end
end

View File

@ -3,7 +3,6 @@ class Post < ActiveRecord::Base
:length => { :minimum => 5 }
has_many :comments, :dependent => :destroy
has_many :tags
accepts_nested_attributes_for :tags, :allow_destroy => :true,
:reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } }

View File

@ -1,3 +0,0 @@
class Tag < ActiveRecord::Base
belongs_to :post
end

View File

@ -14,12 +14,7 @@
<b>Content:</b>
<%= @post.content %>
</p>
<p>
<b>Tags:</b>
<%= join_tags(@post) %>
</p>
<h2>Comments</h2>
<%= render @post.comments %>

View File

@ -1,12 +0,0 @@
<%= form.fields_for :tags do |tag_form| %>
<div class="field">
<%= tag_form.label :name, 'Tag:' %>
<%= tag_form.text_field :name %>
</div>
<% unless tag_form.object.nil? || tag_form.object.new_record? %>
<div class="field">
<%= tag_form.label :_destroy, 'Remove:' %>
<%= tag_form.check_box :_destroy %>
</div>
<% end %>
<% end %>

View File

@ -1,11 +0,0 @@
class CreateTags < ActiveRecord::Migration
def change
create_table :tags do |t|
t.string :name
t.references :post
t.timestamps
end
add_index :tags, :post_id
end
end