1

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!

3
  • 1
    We need more details. Note that we are not you and we don't understand your project. Please describe the context, what you need, what you expect to happen, and what is happening. Commented Aug 20, 2013 at 2:54
  • Not sure what the problem here is, you need to be more explicit. Anyway, I just checked your code and this is just wrong. That code should be included in the user model class. Check this tutorial. Commented Aug 20, 2013 at 3:04
  • I edited the description to hopefully make it easier to understand, my bad. I will look at that tutorial now. Commented Aug 20, 2013 at 3:20

1 Answer 1

2

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 ]
Sign up to request clarification or add additional context in comments.

7 Comments

I tried uncommenting that, but that didn't work. Seems like it's on the right track though!
Try config.authentication_keys = [ :username ] instead.
Did you restart your application after change the setting?
Yes, I did restart my app after changing.
Wow, it worked! Thank you so much! That must have been an update in Devise or something since it wasn't mentioned at all in the tutorial. That's the one thing I don't like about most Rails tutorials: sometimes they say, "It just works!" and don't explain how or why it does, but troubleshooting definitely got me thinking more.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.