mirror of https://github.com/rails/rails
New Getting started guide wont have tags
This commit is contained in:
parent
f6d5036dd6
commit
dbb4c4ddb6
|
@ -1,5 +1,2 @@
|
|||
module PostsHelper
|
||||
def join_tags(post)
|
||||
post.tags.map { |t| t.name }.join(", ")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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? } }
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
class Tag < ActiveRecord::Base
|
||||
belongs_to :post
|
||||
end
|
|
@ -14,12 +14,7 @@
|
|||
<b>Content:</b>
|
||||
<%= @post.content %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Tags:</b>
|
||||
<%= join_tags(@post) %>
|
||||
</p>
|
||||
|
||||
|
||||
<h2>Comments</h2>
|
||||
<%= render @post.comments %>
|
||||
|
||||
|
|
|
@ -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 %>
|
|
@ -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
|
Loading…
Reference in New Issue