Reputation: 688
I understand that I don't have Facebook set up yet (that seems like a similar but different beast), but for right now, based on my understanding, I should be able to sign in with my Twitter username and it say "You signed in!" and display my username where it says
<span>Logged in as <%= current_user.username %>.</span>
Also, on a slightly separate note, I would love to know why flash.notice
isn't working for me. Is that deprecated in Rails 4 or am I missing something in my application.html.erb file for them to show?
I'm working from: http://railscasts.com/episodes/235-devise-and-omniauth-revised
Here is the code I'm currently working with.
https://github.com/erosenberg/devise-app
Edit: Ok, sorry I wasn't very specific, I figured my wall of text would get less responses so I shortened it.
Essentially I'm trying to work with that Railscast to get Devise working with Omniauth. In the past I've gotten Omniauth as well as Devise working on their own, and bringing them together has been a whole new challenge -- considering every tutorial has told me to do it a different way and all of them seem outdated. The way I have it set up is the way that the RailsCast recommends -- to add an OmniAuthCallbacks controller, but that seems to not do anything. When I try signing in with Twitter using my app, it simply takes me back to the sign-in page, however, when I try signing in with an email address, it works and takes me to the "dashboard" that I've created. For some reason the Twitter login isn't working, and I would also like to be able to test using flash[:notice] but for some reason that isn't working either. I would like to also get Facebook login working and have a user be able to merge their account with Twitter or Facebook.
If you need me to explain in even further detail, I can try to do that too. Thanks!
Upvotes: 1
Views: 3621
Reputation: 821
In your config/initializers/devise.rb you didn't change the config.
config.authentication_keys = [ :email ]
Which means it using email to authenticate by default. So the code you missing is saving user's email or will validate failed.
You can either change the authentication_key or save the email.
EDIT
Ok after I clone the app and run on my machine. I'm sure it's because the email validation failed. Because when you using the devise generetor to create the migration file here, Devise validate email has to be presence by default.
t.string :email, :null => false, :default => ""
So you can rollback to change this migration to remote ':null => false'. After that add this code to user user model:
def email_required?
false
end
And don't forget to change your config to get correct authenticate key.
config.case_insensitive_keys = [ :username ]
config.strip_whitespace_keys = [ :username ]
Upvotes: 2