Search code examples
ruby-on-railstwitterdeviseomniauthflash-message

flash error messages if logged in by facebook/twitter with omniauth


When users signup with twitter on my app, they get an error message for email (because twitter does not provide email). The error message is "Email Can't be blank"

How can I make the error message show instead "please enter your email address" if the user has just been redirected from twitter? My error messages are set up as follows:

- if resource.errors.any?
  - resource.errors.full_messages.each do |msg|
    .text-error= msg

Thanks in advance!


Solution

  • I think you should do it another way around. Remove email requirement from omniauth (and remember about db not null & unique.
    Then, upon sign up if there's no email in newly created record redirect to separate page asking to fill it in.
    Once I happened to me that a user from facebook didn't have an email provided as well (and I am askng for email permission) so better be prepared.