Register with a username using Ruby on Rails Devise Gem - ruby-on-rails

Using Devise Gem, I was able to sign in and register via email, but how can I login with username?How can I add validation to a username?

Check devise wiki, should be enough to solve this.
https://github.com/heartcombo/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address

Related

Devise - LogIn parameters invalid email and password

I am new to RoR and I used devise gem for authentication.
I have a login form which is created by command "rails g devise:views"
If I change the form_for(:session,.......) it shows invalid email and password and if I change to form_for(:user,......) it is working.
Questions:
1)Why only user resource not any other resource or controller because the first parameter is for only use for params i.e, params[:session][email].
2)Where is it documented in Devise gem docs?
Can anyone please help me with this issue ?
Thanks in advance !!!!Sorry for silly doubt!

Is this the correct way for only allowing logins via Devise + Omniauth in Rails 4?

I wanted to allow users to signup + login to a Rails app via omniauth only, no email / password sign up / login should be allowed So I looked at this answer, but that didn't work. So I ended up generating customized views for registrations and sessions and commenting out email/password fields in the login + signup forms.
Then in config/initializers/devise.rb I set:
config.params_authenticatable = false
Is this the best way to do it?
I believe there isn't a very "clean" way to do this, because Devise is a very complete solution.
Please take a look here: Using only omniauth (twitter) sign-in with Devise, Rails 3, Omniauth
IMO, if you need just oauth authentication, maybe devise is too much for this. This Railscast may help you as well: Simple OmniAuth

Rails Engine + omniauth-google-oauth2 + Devise gem

Am writing a rails app and a engine. Engine contains Authentication and Authorization process (Here am using GMail login- google_oauth2 gem). After Successful login i have to start session using Devise gem then i have to redirect to sample app.
Problems:
How can i start session after Success message from google? because
here i have to use Devise for session.
What are all the parameters i have to send to devise then how to call
devise's session controller from my engine?
Is there any tutorial to add devise with engine(google-oauth2
gem) please provide links.
If question not clear please tell me i will provide some more details

how to create login form using ruby on rails in ruby mine?

How to create a login form using ruby on rails in rubymine?? i want fields such as username and password and a submit button.when the user clicks submit button username and password must be checked against a mysql database.if the username or password don't match then there must not be login but if the username and password do match it should be redirected to a page. how to do this??
One of the best methods to authenticate a USER against Username and Password :
1. Authlogic
RailsCast : Authlogic
RailsCast : Authlogic : Asciicast
2. Devise
RailsCast : Devise
Learn Ruby on Rails from Ruby On Rails Tutorial
See the sign in section in the same tutorial

Devise access params in Devise sessions view

I'm on Rails 3.0.9, Ruby 1.9.2, Devise 1.3.4
URL to an authenticated Devise resource for my app, e.g.,
http://myblog.com/article/5?type=blah
This will cause Devise to redirect to a login page. I have a need on Devise login page, sessions#new.html.erb, to conditionally display a drop down depending on type and I have no idea how to access it from sessions#new.html.erb. I tried params and that didn't work, ideas?
I found a workaround, Devise stores that info in a session variable
session[:user_return_to]
Hope this helps someone else out of a jam if they need to do the same thing

Resources