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: <b><%= @article.name %></b> </p> <p> Topic: <b><%= @article.topic %></b> </p> <p> Description: <b><%= @article.description %></b> </p> <div id ="notice"></div> <%#*<div id="comments_count">%> <%#= pluralize(@article.comments.size, ''comment'') %> <%#*</div>%> <div id ="comment"></div> <%= render :partial => "comments/comment", :collection => @article.comments %> <%= form_for(@comment, :url => user_article_comments_path(@user,@article), :remote => true) do |f| %> <div class ="field"> <%= f.label :comment %><br/> <%= f.text_area :comment, :cols => "60", :rows => "10" %> </div> <div class="action"> <%= f.submit ''Post Comment'' %> </div> <%end%> <%#*<div id="comments">%> <%#= render :partial => "comments/comment" %> <%#*</div>%> 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. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 16, 9:39 am, guru <urjit.raj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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| > endbecause 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 16, 2:47 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Dec 16, 9:39 am, guru <urjit.raj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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 > > 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. > > Fredthanks for your answer . so how do i render the parcial? can you explain/ thanks. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 16 December 2011 15:28, guru <urjit.rajgor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Dec 16, 2:47 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > On Dec 16, 9:39 am, guru <urjit.raj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 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 > > > > 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. > >thanks for your help but I solved it.> -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- regards Urjit Rajgor -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.