I was looking at an AWDR book on web development with rubies on rails, and one of the problems with the old code was that it did not use response_to to make sure that the view used would be a javascript view. Now, in some updated examples, I saw people mention them later, when applying graceful degradation, use request.xhr? to indicate if javascript is enabled and if they do not redirect the user.
I was wondering if you can use response_to to get the same behavior, and if so, if it is considered good shape or not, and why?
So what I'm thinking of doing something like:
def function
respond_to do |format|
format.js do
basic_stuff
end
format.html do
basic_stuff
user_redirect
end
end
end
, sorta DRY, , , - , . , API .