Hi Bryan,
Thanks for looking at this.
The tip on 'rake routes' really helps.
I tried different variations of your suggestions. The
users_controller.rb
stumbled on
if valid?
so I stripped everything out and just tried:
def login
respond_to do |wants|
wants.html { hobo_login }
wants.js { hobo_ajax_response }
end
end
The above did give me an AJAX response, but did not log me in.
So, I ended up not adding the above to the users_controller.
The partial I am loading, 'padlogin' has this in it:
<login-form update="archsignup" />
That, in combination with changing the form definition and adding the
<do> statement
have gotten me to the point where I get logged in, and it is with an
AJAX method.
However, I can not get the 'def login' in users_controller working
where I can do
the next step of actually loading in another partial into the <div
id="archsignup">,
where everything is landing.
So, if you happen to have one last thought on that I would be
interested in hearing it.
Cheers,
Jet
On Oct 19, 8:05 am, Bryan Larsen <[email protected]> wrote:
> I've never used link_to_remote -- that's a function from
> PrototypeHelper, and I do things either the "Hobo way" or I use jQuery.
> It may well be that link_to_remote is appropriate, but it's not in my
> bag of tricks.
>
> Here's what I'd do in your situation. Note that it's not necessarily
> optimal -- other Hobo'ers can chime in if I'm missing something.
>
> The first thing I'd do would be to split out the login form from the
> login page. Actually, I'm quite surprised it's not already that way.
>
> <def form="login-form">
> <form action="&request.request_uri" class="login" merge>
> ...
> </form>
> </def>
>
> You may have to replace request.request_uri with user_login_path so that
> the form will work on pages other than the login page.
>
> Then I'd include it inside my page, including the magic Hobo ajax keywords:
>
> <do part="login-part">
> <if test="&logged_in?">
> ...
> </if>
> <else>
> <login-form update="login-part" />
> </else>
> </do>
>
> For most Hobo actions, this would be sufficient. However, it appears
> that hobo_login is not ajaxified. (Try it first -- I didn't check the
> code very closely)
>
> After confirming it didn't work, I'd add this to users_controller.rb:
>
> def login
> if !request.post?
> hobo_login
> else
> respond_to do |wants|
> if valid?
> wants.html { hobo_login }
> wants.js { hobo_ajax_response }
> else
> wants.html { hobo_login }
> wants.js { hobo_ajax_response }
> end
> end
> end
> end
>
> Yes, I know that the two parts of the if statement are identical. I'd
> probably add a flash statement in the failure clause and ensure that
> it's displayed inside of login-form.
>
> This is all off the top of my head, I probably made a mistake or two
> somewhere. If you get it to work, please reply with corrections.
>
> And if it works for you and nobody suggests anything better, please
> raise two tickets on the Hobo lighthouse: one to split out login-form
> and the second to ajaxify hobo_login and friends.
>
> To answer your other questions, I find "rake routes" very handy.
>
> Looking at that, it implies that it's the login action on the
> users_controller. The code for that is in
> hobo/lib/hobo/users_controller.rb. The default is essentially just "def
> login ; hobo_login ; end", which is why the above definition works.
>
> Unlike most other hobo actions, it appears that login isn't split into
> "login" for the GET and "do_login" for the POST.
>
> cheers,
> Bryan
>
> blueHandTalking wrote:
> > I currently have a login form that gets loaded into a partial on my
> > current page.
> > This happens by using link_to_remote, which does the following:
>
> > :update => 'archsignup', :url => {:controller => 'users', :action =>
> > 'padshowlogin'}
>
> > In my form, I just used the action from the Hobo login form:
>
> > <form action="&request.request_uri" class="login" success="(stuff here
> > that never gets executed :( )...>
>
> > So what happens when this form is submitted, is that the action which
> > I used to load the form with,
>
> > :action => 'padshowlogin'
>
> > seems to fire off using the url of partial in padshowlogin, and
> > displaying login form again, albeit in a very rough fashion. I do
> > get logged in correctly, so that is good.
>
> > The display of the login form again is not at all what I would like to
> > happen. The problem is that I do not understand what action is called
> > with:
>
> > action="&request.request_uri" class="login"
>
> > An action from the login controller? New? Create?
>
> > What I would like to do when logging in, is to update a partial in my
> > current page.
> > I do not know what action I would call. Especially I do not understand
> > how I can get an AJAX update
> > when I have specified action="&request.request_uri" class="login", as
> > I thought that once that was
> > done, Hobo lost its 'smarts' and would not do an update. So, is there
> > another way I can fire off the
> > login action so as to make this an AJAX request?
>
> > I hope what I have said is clear to someone, since my understanding is
> > a bit murky about this
> > I am not sure if I have been able to explain it in a lucid fashion.
>
> > Thanx.
>
> > jet
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" 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/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---