Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add new action into Devise registrations controller?

I know how to override default controllers and it is working, but now I need to add new action into Registrations controller.

I need to update user fields. I need to add First and Last name in this form, but I don't want to use standard edit page, because it will be separate page.

So I need other page. I have paypal..html.erb in my registrations folder, but I can't render it from action in 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 render new registration file. Here is error:

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

How I can use update form to do this and what I'm doing wrong ?

like image 963
MID Avatar asked Aug 16 '12 09:08

MID


1 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
like image 187
kitwalker Avatar answered Oct 18 '22 18:10

kitwalker