1

Forgive the title - I'm not 100% sure how to summarize the question.

My application is a Rails 4 app, using Devise with Oauth2. The goal of the app is a simple questionnaire, with one question. As the "submit" button of the form, I would like to have a button that is "sign up / sign in" with Facebook.

I have Oauth2 working with Facebook - it creates an account (if one doesn't exist), etc. - but what I can't figure out is how to pass the answer_id and question_id past the Oauth2 call in order to persist that to the database after the user has successfully authenticated with Facebook.

I understand that I can pass custom key/value pairs to the omniauth_authorize_path call in Devise, but that seems like it might be problematic as I'd have to use JavaScript to determine the option chosen by the user. I'm specifically referencing this SO question and answer with regards to this possible solution.

So, I guess my questions are, is the above the right idea and just pass answer_id and question_id through omniauth_authorize_path and read it after, or is there another solution, perhaps a POST to /answers, which would somehow make an Oauth2 call in my AnswersController?

Additional information that might be helpful:

class User < ActiveRecord::Base
  has_many :answers
end

class Answer < ActiveRecord::Base
  belongs_to :question
  belongs_to :user
end

class Question < ActiveRecord::Base
  has_many :answers
end
Community
  • 1
  • 1
CDub
  • 13,146
  • 4
  • 51
  • 68

0 Answers0