我正在使用rails 4来设计这个包含articles、comments和users的博客。
非常好,我只想在索引页面中列出文章及其下面的注释。
在每篇文章下使用ajax注释表单(通过javascript创建新文章),我的代码
显示没有错误,但是拒绝出现的表单可能是做错了什么。将要
粘贴
所有密码这样我才能被纠正..。
我的index.html.erb
<h1>Articles</h1>
<% @articles.each do |article| %>
<%= render :partial => article %>
<%= render :partial => article.comments %>
<% form_for ([article, Comment.new],:remote => true) do |f| %>
<p>
<%= f.label :content, "New Comment" %><br/>
<%= f.text_area :content %>
</p>
<p><%= f.submit "Add Comment"%></p>
<% end %>
<% end %>
<p><%= link_to "New Article", new_article_path %></p>第一个部分代码<%=呈现:分部=>文章%>
<h2><%= link_to article.name, article %></h2>第二部分<%=呈现:部分=> article.comments %>
<%= div_for comment do %>
<p><strong> <%= comment.user.username %> says</strong></p>
<%= simple_format comment.content %>
<% end %>上面的代码没有抛出任何错误,但是表单拒绝显示任何帮助。
还是有更好的方法去做呢?
发布于 2014-03-10 21:56:11
替换
<% form_for ([article, Comment.new],:remote => true) do |f| %>使用
<%= form_for ([article, Comment.new],:remote => true) do |f| %>缺少=标志,通知再培训局评估和显示结果。
https://stackoverflow.com/questions/22312085
复制相似问题