If the request is getting the correct method which creates comment, then the request is probably working correctly.
I usually try to use the create methods for a model in the corresponding controller, so if I create a new comment (even if its originates from the stories view), I simply format my ajax request to link to the /comments/create method in the comments controller and build the create.js.rjs or create.js.erb file in the views/comments directory, that way I can reuse that code elsewhere should the need arise. This probably works better with the js.erb file since you can use classes to select elements, instead of just by the element ID that js.rjs requires. The only thing I can see that might be wrong in your rjs code is the location of the partial. Usually, if you are specifying a partial or view in a different directory the url would look something like ''/ users/pig" Personally I don't like working with rjs , unless I have to, and I usually convert that code over to a js.erb file if I can. On Aug 4, 1:10 pm, Neil Bye <[email protected]> wrote: > Joshua Mckinney wrote: > > Just to be clear, this is an ajax request correct? TRUE > > > I believe your create method is inside your comments controller, TRUE > > > You could try to use the render method to specify the location of the > > view like (i have not tried this with an ajax request): > > render => '/stories/create' > gives errors > > > > > or place the create.js.rjs in the comments views folder > > There is a copy in views/comments but look at the attached screenshot. > The pig is created by the 'add a fox' link using > <%= link_to_remote("Add a fox", > :url =>{ :action => :add }) %>. > The relevant rjs file is views/stories/add.rjs nb it is in stories and > has a .rjs extension. It evidently works. This suggests to me that the > fault must be in the ajax request. Here it is > > <% remote_form_for :comment, :update =>'aremark', > :url=>story_comments_path(@story) do |form| %> > <div id="body"><%= form.text_field :body %></div> > <p><%= submit_tag 'Comment' %></p> > > Can you see anything wrong? > > This is add.rjs > > page.insert_html :bottom, 'aremark', :partial => 'user/pig' > page.visual_effect :highlight, 'aremark', :duration => 8 > page.replace_html 'header', 'pig' > > In peace Neil > > Attachments:http://www.ruby-forum.com/attachment/4904/Screenshot-2.png > > -- > 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 [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.

