REST and AJAX Validators


#1

So what’s the ‘right’ way to deal with AJAXY validators under REST?

Say I have an observe_field that checks against taken usernames, where
do I
stick the available_user method? … it doesn’t seem to fit in the
RESTful
user_controller, do I just create another controller to store all my
AJAX
cruft that is non-REST, or is there a more
official/sanctioned/opinionated
way to do this?


#2

On Wednesday 14 March 2007, Fluffy Hippo wrote:

So what’s the ‘right’ way to deal with AJAXY validators under REST?

Put them in the controller that handles the resource.

Say I have an observe_field that checks against taken usernames,
where do I stick the available_user method? … it doesn’t seem to
fit in the RESTful user_controller,

REST is a guideline, not a straitjacket.

Michael


Michael S.
mailto:removed_email_address@domain.invalid
http://www.schuerig.de/michael/


#3

On Mar 14, 9:01 am, “Fluffy Hippo” removed_email_address@domain.invalid wrote:

So what’s the ‘right’ way to deal with AJAXY validators under REST?

Say I have an observe_field that checks against taken usernames, where do I
stick the available_user method? … it doesn’t seem to fit in the RESTful
user_controller, do I just create another controller to store all my AJAX
cruft that is non-REST, or is there a more official/sanctioned/opinionated
way to do this?

What would available_user do? My guess is, given a potential user
name, see if a user with than name already exists, right?

In that case, perhaps your ajax call would just call myapp.com/users?
name=‘potential_name’ and see if you get a 404 back (no user found) or
a 200 (which could mean that the user was found).

This way you’re still RESTful, just look for query parameters that
help refine your query.

Would that work?

Jeff
softiesonrails.com