0
我正在工作一個非常簡單的論壇軟件,以幫助我的腳在軌道上的紅寶石溼。我所試圖做的就是添加一個文本區域,帖子內容,當用戶創建一個新的話題,但每次我試圖在專題的形式將其添加,我得到以下錯誤:如何包含來自其他對象的表單元素?
NoMethodError in Topics#new
Showing /Users/Ken/dev/forums/app/views/topics/_form.html.erb where line #11 raised:
undefined method `merge' for :content:Symbol
這裏的我的新主題形式:
<%= form_for @topic do |f| %>
<%= f.error_messages %>
<% if params[:forum] %>
<%= f.hidden_field :forum_id, :value => params[:forum] %>
<% end %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.text_area :post, :content %>
</p>
<p><%= f.submit "Create" %></p>
<% end %>
這裏是我的主題模式:
class Topic < ActiveRecord::Base
attr_accessible :name, :last_poster_id, :last_post_at
belongs_to :forum
has_many :posts, :dependent => :destroy
end
這裏是我的Post模型:
class Post < ActiveRecord::Base
attr_accessible :content
belongs_to :topic
end
如何在主題表單中正確使用文本區域?我是否需要將其添加到主題模型才能訪問它,如果有,我該怎麼做?