Im using the ‘Devise’ gem on a rails 3.1.1 app for creating users and signing in, but i need to add fields for profile as @user.build_profile but i dont know where to add this, i also need to change the default redirect_to after signing in.
Share
You can add the fields that you need to your models just as you normally would through a migration. If you are using the default devise views through
rails generate devise:views, then you will want to add your fields to thenewandeditviews inside of the Registration views in devise.As for changing the default redirect after sign_in, I would start with reading the Devise Wiki. You can simply add to your application controller:
This will allow you to customize that route. You can also look at the registrations controller within devise to see the other methods that you can override.
Edit:
Overriding the controller:
You would create your own controller that inherits from
Devise::RegistrationsController. From there you only need to specify the methods that you need to override, and not every single one. For instance:Then add the above lines for
stored locationandafter_sign_in_path. You also have to tell Devise in yourroutes.rbto use your new controller with,devise_for :users, :controllers => { :registrations => 'your_controller_name }I have an example of this on my blog, and the full source is on Github.