4

I started using Devise for a project and I'm a bit disappointed because everything is so hardwired somewhere deep in the Devise Gem. I find it very difficult to create a custom Sign Up or Sign In process.

What I'm trying to do is show a simple signup form anywhere on my site (solution found here: http://pupeno.com/2010/08/29/show-a-devise-log-in-form-in-another-page/ ) and submit it with jQuery.post, retrieve the result, update error messages and finally sign up the user.

I don't find this documented anywhere. When I submit my form this way I catch an exception saying missing template. It would be much easier if I could customize the Controller and Actions and do everything myself.

Has anyone a solution, a link, a blog post, whatever to help me here? Thanks!

Ole Spaarmann
  • 15,845
  • 27
  • 98
  • 160

1 Answers1

4

You can completely customize each controller in Devise. All you need to do is create your controller and have it inherit from the Devise controller like so:

class RegistrationsController < Devise::RegistrationsController

You can then override any of the actions in the method. You can see all of the default methods by checking their Github account for each controllers methods. Any method that you want to leave default you can either leave out, or just call super in the method.

def new
  super
end

I often find that I need to customize Devise in this way to suit my needs. As for you view needs, you can install the Devise views through rails g devise:views and then copy them to wherever in your application you would like them.

Lastly I would check the Devise wiki on their Github pages. There are tons of useful examples, on how to bend Devise to your will, and of course the community is here to help.

janders223
  • 3,123
  • 2
  • 22
  • 27