How to add a new action to the Devise registration controller?

I know how to override the default controllers, and it works, but now I need to add a new action to the registration controller.

I need to update user fields. I need to add the first and last name in this form, but I do not want to use the standard editing page, because it will be a separate page.

I need another page. I have paypal..html.erb in my registration folder, but I cannot do this from the action in the regustrations controller.

Paypal Action:

class RegistrationsController < Devise::RegistrationsController def paypal end ... end 

routes.rb:

  devise_for :users, :controllers => {:registrations => 'registrations', :sessions => 'sessions'} do match 'paypal' => 'registrations#paypal' end 

but somehow it displays a new log file. Here is the error:

  NoMethodError in Registrations#paypal Showing C:/1508/app/views/devise/registrations/new.html.erb where line #22 raised: 

How can I use the update form for this and what am I doing wrong?

+8
override ruby-on-rails devise
source share
2 answers

I added this to my routes to make it work.

 devise_scope :user do get 'paypal(/:id)', :action => 'paypal', :controller => 'user/registrations', :as => 'paypal' end 
+1
source share

Your question seems a bit unclear, but why not explicitly visualize the view?

 def paypal render 'devise/registrations/paypal' end 

If you have multiple users, it is better to highlight paths and routing.

https://github.com/plataformatec/devise/wiki/How-To%3a-Customize-routes-to-user-registration-pages

0
source share

All Articles