Problen in ajax using rjs

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’) %>
<%#
%>

<%= render :partial => "comments/comment", :collection => @article.comments %>

<%= form_for(@comment, :url =>
user_article_comments_path(@user,@article), :remote => true) do |f| %>

<%= f.label :comment %>
<%= f.text_area :comment, :cols => "60", :rows => "10" %>
<%= f.submit 'Post Comment' %>

<%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.

On Dec 16, 9:39am, guru [email protected] wrote:

 render :update do |page|
 end

because you’re calling render :update here, your template isn’t
getting rendered (much like if you were to tall render :text => ‘OK’,
that would also suppress ‘normal’ template rendering.

Fred

On 16 December 2011 15:28, guru [email protected] wrote:

if @comment.save

that would also suppress ‘normal’ template rendering.

Fred

thanks for your answer .
so how do i render the parcial?
can you explain/
thanks.

thanks for your help but I solved it.


You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


regards
Urjit Rajgor

On Dec 16, 2:47pm, Frederick C. [email protected]
wrote:

params[:article_id] ) }
format.js {
render :update do |page|
end

because you’re calling render :update here, your template isn’t
getting rendered (much like if you were to tall render :text => ‘OK’,
that would also suppress ‘normal’ template rendering.

Fred

thanks for your answer .
so how do i render the parcial?
can you explain/
thanks.