Devise controllers rails

前端 未结 2 1891
醉酒成梦
醉酒成梦 2021-02-06 16:39

I\'m using Rails 3, on ruby 1.8.7. And using for auth. devise (1.1.3). But it is a quite large community site i\'m building, so i have a table for profiles and a table for users

2条回答
  •  后悔当初
    2021-02-06 17:28

    You can subclass the Devise RegistrationsController and add your own logic in the create() method, and call the parent class methods for everything else.

    class MyRegistrationsController < Devise::RegistrationsController
      prepend_view_path "app/views/devise"
    
      def create
        super
        # Generate your profile here
        # ...
      end
    
      def update
        super
      end
    end
    

    If you want to customise the Devise views that are packaged inside the Gem then you can run the following command to generate the view files for your app:

    rails generate devise:views
    

    You will also need to tell the router to use your new controller; something like:

    devise_for :users, :controllers => { :registrations => "my_registrations" }
    

提交回复
热议问题