Say I have the models User and Project. Users and projects are HABTM-associated. My setup is actually a bit more complicated than this, but I think for the purposes of my question this will do.
Now, I want to use omniauth to authenticate a particular project with Twitter, Facebook, what have you. I’ve figured out how to define my omniauth path_prefix, but I don’t know how I could pass in a variable like so: config.path_prefix = 'projects/:project_id/auth', much less make a custom callback url like project/:project_id/auth/twitter/callback.
For posterity’s sake, I solved it this way:
I added an
authmethod to my projects controller, which set a session variablesession[:auth_project_id]and then redirectes toauth/ + params[:provider].In my callback controller
authentications, I got my project with@project = Project.find(session[:auth_project_id]), created the authentication, and thensession[:auth_project_id] = nilto unset the session variable.