我在我的 Rails 应用程序中集成了 google 和 facebook omniauth。注册和登录效果很好。但是,我也有一个应该与omniauth 一起提交的表单,这样我就可以将表单内容作为参数访问。
这是一段代码:
%section#hero.hero-blk
.container
.intro.text-center
%h1 Ask Question Instantly
%h3.hero-tagline Ask anonymously anytime
.row
.col-md-6
.ask-question
%h2.text-center Talk to us
%form{method: 'post', action: new_forward_questions_path}
=hidden_field_tag :authenticity_token, form_authenticity_token
%textarea.form-control{:autofocus => "", :cols => "20", :id => "question-content", :name => "content", :placeholder => "Describe your question on relationship, marriage. Please type atleast 50 characters", :rows => "7"}
%div#chars-left
%input{type: 'hidden', name: 'source', value: 'home'}
.text-center
%button#ask-button-index.glow-button.btn.btn-primary{type: 'submit'}
%img{:alt => "", :src => image_path("incognito-new.svg")}/
Ask Anonymously
.modal-body
#dialog-loading-icon.collapse
%p
Please wait, submitting your question
=image_tag "ripple.gif"
= simple_form_for @question do |f|
= f.input :content, as: :hidden, input_html: {id: 'hidden_question_content'}
- if current_user.nil? or current_user.asker.nil? or current_user.asker.new_record?
.social-sign-in.visitor-oauth.text-center
= link_to "Sign up with Gmail", user_google_oauth2_omniauth_authorize_path(@question), class: "zocial gmail"
= link_to "Sign up with Facebook", user_facebook_omniauth_authorize_path, class: "zocial facebook"
下面是生成的 html 的屏幕截图如您所见,模态表单填充了“Oauth Oauth Oauth”这是我在 textarea 中编写的内容,当我单击按钮时,模态弹出并具有相同的内容我键入:
我试过在这里传递@question,但没有通过。在控制器中,我试图通过request.env["omniauth.params"]访问参数,但它始终为空白。
如何访问或将此内容参数传递给omniauth 并在控制器中访问它?