[Rails 3.0.9] I have trouble about fields_for

Hi,all. I’m new bee to Rails and I have trouble about fields_for
method…
It isn’t show up between the <%= f.fields ~ <% end %>

Please teach me some advice.
Thanks!

#new/_form.html.erb
<%= form_for(@user) do |f| %>

<%= f.label :name %>
<%= f.text_field :name %>
<%= f.fields_for :entry do |entry_form| %>

  Title:<br/>
<%= entry_form.text_field :title %>


<% end %>
<br/>
<%= f.submit "Create" %>

<% end %>

user.rb

class Entry < ActiveRecord::Base
belongs_to :user
end

entry.rb

class User < ActiveRecord::Base
has_many :entries
accepts_nested_attributes_for :entries

end

On 25 July 2011 10:07, harashin [email protected] wrote:

<%= f.label :name %>
<%= f.text_field :name %>

<%= f.fields_for :entry do |entry_form| %>

<%= f.fields_for :entries do |entry_form| %>

You can’t refer entries as entry in your form. I think you want a
has_one relationship between user and entry.

On 25 July 2011 11:39, Sameer R. [email protected] wrote:

You can’t refer entries as entry in your form. I think you want a
has_one relationship between user and entry.

if user has_many entries then in the form you can do fields_for :entries

Thanks Maruo,Sammer! I edit the entry to entries. And I add new Action
to

@post.tags build
then it worked fine!
But I don’t know @post.tags.build mean. Please teach me about this mean?

#post_controller.rb

def new
@post = Post.new
@post.tags.build

tags is table name.

table name : tags
table columns *tag_name

tnanks!