begore_filter and XHR/Ajax calls

What's the best way to do a javascript alert warning when someone is
trying to access a ajax method that requires authentication - for
example to rate a recipe, I have a star-based ajax/css interface. To
actually add a rating you need to be logged in. When I use the
before_filter, it just redirects to the login page - I'd like to show
an alert that says something like "to add a rating, please register/
login first" right there - what's the best way to do this?

Your before_filter stuff is just regular code. It can do a render :update for example just as easily as it does a redirect.


That was a helpful answer - thanks Fred.