I have a form that accepts comments and adds them to a list without refreshing the page. This is the html: <div id=''aremark''> <%= render :partial => ''comment'' %> </div> <% remote_form_for :comment, :url=>story_comments_path(@story), :html => { :id => ''comment'' } do |form| %> <h5><label for="login">Make a comment:</label></h5> <div id="body"><%= form.text_field :body %></div> <p><%= submit_tag ''Comment'' %></p> <% end %> The form works i.e on refreshing the page the new comment is seen in the comment partial. From comments_controller def create @story = Story.find(params[:story_id]) @story.comments.create params[:comment] flash[:notice] = "Thank you for commenting" end This is create.rjs <script> aremark = page.getElementById("aremark") page.replace_html(''aremark'', :partial => "content") </script> This was working then didn''t. I don''t know what I did to break it. Can anybody see where I am going wrong? -- Posted via http://www.ruby-forum.com/. -- 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.
Neil Bye wrote:> I have a form that accepts comments and adds them to a list without > refreshing the page. >It should read I want a form that accepts comments and adds them to a list without refreshing the page. -- Posted via http://www.ruby-forum.com/. -- 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 Jul 27, 8:56 pm, Neil Bye <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> This is create.rjs > > <script> > aremark = page.getElementById("aremark") > page.replace_html(''aremark'', :partial => "content") > </script> >This is weird - if it''s an rjs file you don''t want script tags - an rjs file only contains ruby. Fred> This was working then didn''t. I don''t know what I did to break it. > Can anybody see where I am going wrong? > -- > Posted viahttp://www.ruby-forum.com/.-- 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.
So I strip it down to page.replace_html(''aremark'', :partial => "content") Still won''t work without refreshing the page Frederick Cheung wrote:> On Jul 27, 8:56�pm, Neil Bye <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> This is create.rjs >> >> <script> >> aremark = page.getElementById("aremark") >> page.replace_html(''aremark'', :partial => "content") >> </script> >> > This is weird - if it''s an rjs file you don''t want script tags - an > rjs file only contains ruby. > > Fred-- Posted via http://www.ruby-forum.com/. -- 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.
In the log I get ActionView::MissingTemplate (Missing template comments/create.erb in view path app/views): Does that help anyone to explain -- Posted via http://www.ruby-forum.com/. -- 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.
Hello, Shouldn''t you be doing page.replace_html from inside your controller and using your rjs page as a paramater passed to page.replace_html?? I think the log is telling you that your request found def create....but without making def create render something other than create.html.erb, won''t the controller be looking for that instead of your rjs template? Oldroy On Jul 28, 6:44 am, Neil Bye <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> In the log I get > > ActionView::MissingTemplate (Missing template comments/create.erb in > view path app/views): > > Does that help anyone to explain > -- > Posted viahttp://www.ruby-forum.com/.-- 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.
Oldroy wrote:> Hello, > Shouldn''t you be doing page.replace_html from inside your controller > and using your rjs page as a paramater passed to page.replace_html??I don''t understand, how would it find the rjs and if the page.replace_htm is in the controller what would it contain? -- Posted via http://www.ruby-forum.com/. -- 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.
Neil Bye wrote:> Oldroy wrote:but without making def create render something other than create.html.erb, won''t the controller be looking for that instead of your rjs template? I think this is the problem but I don''t know the solution. Surely in the absence of create.html.erb it should find create.rjs but doesn''t????????????? -- Posted via http://www.ruby-forum.com/. -- 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.