Devise redirect after sign up fails - ruby-on-rails

Is there any easy way to disable devise sign_up page? I have forms for registration and authorization on one page so i don't need any other pages. I want to disable routes responsible for these pages, so that if a user enters users/sign_up he should't get to the sign up page but should be redirected to some other page.

You can overwrite the registrations controller and make the new action redirect somewhere. Here are some responses to a similar question that was posted on StackOverflow which explain the necessary steps.

Related

Ruby on Rails, how to stop navbar rendering on Log-In page?

In my application a user is taken straight to log-in before they can enter the main site.
I am rendering a navbar partial across the site but I don't want the navbar rendered on the log-in page. I don't want to have to copy and paste the navbar code in to all the views in order to prevent this.
It would be cleaner if there was a way I could stop the navbar showing on the login screen without having to remove the partial.
How do you restrict a partial view from one page in your application?
I am using Devise.
I don't think code is needed in this post but happy to provide if helps. Thanks.
If you are using Devise and you are in a login page, then there is no logged user. Then you may use one of the Devise helpers to achieve what you want. Something like:
if (not user_signed_in?) then
render 'your_partial_with_the_navbar'
end
The only point here is the fact the partial wouldn't render in any page where there is no user logged.
You could also create a better helper yourself, combining the user_signed_in? from Devise with other conditions of yours.

How to programmatically sign in a user through Devise in Rails

I need to have a custom mechanism for signing in using Devise with Rails 4. So I found the sign_in method in Devise's test helpers section of their documentation:
sign_in #user # sign_in(resource)
But is that the proper way to sign someone in from the web? In particular, will it do all the things Devise does when a user signs in, like recording the date/time stamps, IP addresses, sign in counts, etc? Or is this just for testing purposes?
Devise offers a bunch of helpers, two of which are these:
sign_in(resource_or_scope, *args)
sign_in_and_redirect(resource_or_scope, *args)
You can use these from any controller.
If using sign_in already works for you but leaves the user on a blank page, check your logfile to see if there is a redirect going on, and where it redirects to. Or just make the redirect explicit by using the second of the helpers above.
References:
https://stackoverflow.com/a/8123646/2034097
It is the proper and standard way to programatically sign a user in. Looking at the devise login code sessions#create you can see they use this method as well.
Long story short: Yes, sign_in #user does all the things that devise would normally do when a user signs in. It could be useful, for example, allowing an Administrator to sign in as one of their users.
How To: Sign in as another user if you are an admin

Devise 3.2.1custom redirect_to on Sign Up.

I am working with Rails 4.0.1 and Devise 3.2.1. After a user signs up I want to save their email address to the database. I then want to ask the user for additional information in the update action on a separate page.
How to I customer Devise's create action so that I redirect the user to the user/update controller action?
Thank you.
You could use after_sign_up_path_for in a newly-created RegistrationsController to control where the user goes after they sign up.
The devise documentation has a wiki article on how to do just this.

Allow only the registration form

How can I create a method that will navigate the visitors to a registration path before (s)he signs in or signs up?
Use a before_filter on your controllers to ensure that users are signed in, with the default action of redirect to registration if they are not.
There is a Gem called Devise which is very useful for authentication and is well worth the effort of learning it.
Another good place to go is http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
This will give you an excellent grounding in Rails

Rails Devise login system. How to customize login flow?

I have been using the devise gem for rails and I have facebook login system working. My problem is that there is so much going on in the background that I find it difficult to customize this. For example how do I change the path to the page the user is redirects to after the first time facevbook login, not the usual facebook login.
It adds this method to my user model
find_for_facebook_oauth
But what decides where it goes after that?
Also, If i make controller and extend the devise controllers will it call the code in the devise ones first? I dont get how that works.
Thanks so much!
Does this page from the devise wiki help you?
How To: Redirect to a specific page on successful sign in

Resources