I am using rails 3. I have problem in out put so please tell me my
mistake
routes
entermatch '/view_article/:user_id/:article_id' =>
‘articles#view_article’, :as => :view_article
resources :users do
resources :articles do
resources :comments
end
end
article controller
def view_article
@user = User.find(params[:user_id])
@article = Article.find(params[:article_id])
@comment = Comment.new
@comments = Comment.find(:all, :conditions => ['article_id =? ',
params[:article_id]])
end
view_article.html.erb
<p>
Article Name:
<%= @article.name %>
Topic: <%= @article.topic %>
Description: <%= @article.description %>
<%#
<%#= pluralize(@article.comments.size, ‘comment’) %>
<%#
<%= form_for(@comment, :url =>
user_article_comments_path(@user,@article), :remote => true) do |f| %>
<%= f.text_area :comment, :cols => "60", :rows => "10" %>
<%end%>
<%#
<%#= render :partial => “comments/comment” %>
<%#
comment controller
def create
@comment = Comment.new(params[:comment])
@comment.user_id = params[:user_id]
@comment.article_id = params[:article_id]
if @comment.save
respond_to do |format|
flash[:notice] = "Comment was Successfully created"
format.html { redirect_to view_article_path(params[:user_id],
params[:article_id] ) }
format.js {
render :update do |page|
end
}
end
create.rjs
page.insert_html :bottom, :comment, :partial => 'comment', :object
=> @comment
page[:comment_comment].reset
page.replace_html :notice, flash[:notice]
_comment.html.erb
<%= comment.user.email %>
<%= comment.comment %>
<%= time_ago_in_words(comment.created_at) %> ago
so problem is when I submit the form entry is made in database but
view article page not show any change and whe i refresh the page then
change is seen.
please do the needful.
Thanks.