0

I'm writing a rails3 app using authlogic and authlogic-oid to allow the user to login and register using their LinkedIn account. I'm able to call out to LinkedIn to authenticate but the issue I'm having is that when the call returns to my rails app, it is calling a GET on /user_sessions and invoking the index controller instead of executing the remainder of the create controller. Here's the controller:

# POST /user_sessions                                                         
def create
  @user_session = UserSession.new(params[:user_session])
  @user_session.save do |result| # <-- redirects to api.linkedin.com here
    if result
      flash[:success] = "Login successful!"
      redirect_back_or @user_session.user_path
    else
      flash.now[:error] = "Invalid username/password combination."
      @title = "Sign in"
      render 'new'
    end
  end
end

Everything works great until if result which never gets called because the program resumes execution in the index controller instead of picking up where it left off. Any ideas on how to fix this would be greatly appreciated.

Edit: it seems my assumption that the controller was not completing execution was wrong. I've put in a bunch of debug statements and learned that the the program does resume execution in this controller after @user_session.save but it is not executing either condition on the if statement. I'm very confused on this one.

spinlock
  • 3,737
  • 4
  • 35
  • 46

1 Answers1

1

if you don't want to use index method in your UserSessionsController then write this: resources :user_session in your route.rb . If you'll use singular form then route can map CRUD (create, read, update, delete) and if you'll use plural of it then it will bind CRUD with index method of your controller.

Surya
  • 15,703
  • 3
  • 51
  • 74
  • Thanks. I've actually been working on this for the past few days and I've realized that @user_session.save does resume execution in this controller, it just skips the conditional statement which is why rails is calling /user_sessions#index. It looks like it's a case where authlogic-oauth isn't playing nice with rails3 – spinlock Mar 20 '11 at 01:31