Forum: Ruby on Rails REST and AJAX Validators

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
26ac39654997d2eaf95eb600652c497e?d=identicon&s=25 Fluffy Hippo (Guest)
on 2007-03-14 15:02
(Received via mailing list)
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?
Bce1d1b7c3ec7b577dcb42e254899e6b?d=identicon&s=25 Michael Schuerig (Guest)
on 2007-03-14 17:15
(Received via mailing list)
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 Schuerig
mailto:michael@schuerig.de
http://www.schuerig.de/michael/
8217faf2bfdfa7daf10135d41ddd421e?d=identicon&s=25 Jeff Cohen (jeff)
on 2007-03-14 17:32
(Received via mailing list)
On Mar 14, 9:01 am, "Fluffy Hippo" <fluffyhi...@gmail.com> 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
This topic is locked and can not be replied to.