hi guys:

I'm scratching my head on this one: I have a twitter app where I'm
trying to open a modalpopup with a twitter sign in, get them to sign in,
then close the popup and refresh the main window. My code however
refreshes the main window with the popup window result, which I thought
was really strange:

application.html.erb


function OpenModalPopUP()
{
     window.showModalDialog('/sessions/create');
}

main page

<%= link_to "login via twitter", {:controller => "sessions/create"},
:onclick => "OpenModalPopUP()" %>

sessions/create

  def create

    oauth.set_callback_url(finalize_session_url)

    session['rtoken']  = oauth.request_token.token
    session['rsecret'] = oauth.request_token.secret

    redirect_to oauth.request_token.authorize_url
  end

sessions/finalize

  def finalize
    oauth.authorize_from_request(session['rtoken'], session['rsecret'],
params[:oauth_verifier])

    session['rtoken']  = nil
    session['rsecret'] = nil

    profile = Twitter::Base.new(oauth).verify_credentials
    user    = User.find_or_create_by_screen_name(profile.screen_name)

    user.update_attributes({
      :atoken => oauth.access_token.token,
      :asecret => oauth.access_token.secret,
    })

    sign_in(user)
#  page << "window.close()"
  redirect_to session[:return_to] rescue redirect_to :controller =>
"home"
#  redirect_to :controller => "sessions/autoclose"
  end

As you can see, by the commented out code, I attempted to push
"window.close()" but it gave me an error message. i then tried to
redirect to another window which autoclosed, but when I did that, it
redirected the main window to autoclose as well. I'm a rails noob, so
I'm guessing that i have to do something  after the redirect to shut
down the process after closing the window, otherwise it will run the
refresh on the main window? Please advise.

also, while i'm at it, do you know how I can resize the modalpopup?

Thanks...chris
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en.

Reply via email to