how to display comment form in the articles index page rails 4 -
i using rails 4 design blog containing articles comments , users everything
works great want list articles in index page , comments underneath
with ajax comment form under each article(to create new articles via javascript) code
shows no error form refused show maybe doing wrong.
paste
all code can corrected...
my index.html.erb
<h1>articles</h1> <% @articles.each |article| %> <%= render :partial => article %> <%= render :partial => article.comments %> <% form_for ([article, comment.new],:remote => true) |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> the first partial code <%= render :partial => article %>
<h2><%= link_to article.name, article %></h2> the second partial <%= render :partial => article.comments %>
<%= div_for comment %> <p><strong> <%= comment.user.username %> says</strong></p> <%= simple_format comment.content %> <% end %> the code above doesn't throw error form refused show please
or there better way of doing ?
replace
<% form_for ([article, comment.new],:remote => true) |f| %> with
<%= form_for ([article, comment.new],:remote => true) |f| %> missing = sign tells erb evaluate , display result.
Comments
Post a Comment