On Nov 6, 11:15 am, David King <[EMAIL PROTECTED]> wrote:
> I have a login_controller that is addressed by its URL at /login.
> Since users get confused by URLs that look like /login/login, I'd
> like the 'index' function to behave just like the 'login' function.
> (That is, I should be able to accept GET and POST actions at /login/
> login and /login.) So I do this:
>
> -module(login_controller).
> -export([index/1,
> login/1,login/2,
> logout/1,
> signup/1]).
> index(A) -> {replace,{ewc,login,login,[A]}}.
> login(A) ->
> case yaws_arg:method(A) of
> 'GET' ->
> {data,{[]}};
> 'POST' ->
> [...]
>
> In theory, that makes 'index' do all of the same things as 'login',
> by actually {replace}ing itself with 'login'.
I actually had the same problem a couple of months ago. It and other
things are discussed in this thread:
http://groups.google.com/group/erlyweb/browse_thread/thread/68535fdf10e41e9d
Scroll down until you see my post starting with "Okay, I finally
understand." That post describes the same problem you're seeing, and
Yariv's reply right after it describes the solution.
To save you time, though, it basically boils down to replace tuples
being rendered as subcomponents, which aren't allowed to return
anything but data and ewc tuples. The solution is to have index/1
call login/1 directly, rather than using a replace tuple. You'll then
have to do the same in the view code.
-Bryan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"erlyweb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---