link_to_remote patterns/idiom

Cory Wilkerson
2008-01-23T01:14:14Z

All,

What''s the current line of thinking wrt patterns/best practices for
remote calls and subsequent page updates?

For instance, let''s say I have a simple link_to_remote call that simple
creates a new comment for a given blog post.  On success, I''d like to
indicate that all was well, on failure, I''d like to give some
indication
as to why.

Obviously, Rails has some nice (and by nice I mean ''programmer
friendly'') abstractions for handling this type of functionality but the
myriad of options has left me in a state of paralysis.

That said, I''m seeking to understand the preferred/recommended way to
pull something like this off:

class CommentController < ApplicationController
  def create_comment
    @comment = Comment.new(params[:comment])
    if @comment.save
      # Should I use RJS here to update the page?

      # Should I return some HTML (sans RJS) and use the prototype
helper to
      # update a DIV?
    else
      # Would obviously look to stay consistent here.
      # Do I use RJS to update the page?
      # Shall I send back a non 2XX status code and use prototype helper
    end
  end
end

What be the prevailing pattern?  Arggh.

TIA!
Cory
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---