0

I'm using devise on Rails.

I want to set some values for the user object variable in the sign up controller create action. for that I want to access the user object

My use case is set the plan_id at sign_up; the url is example.com/users/sign_up?plan_id=1

I want to set that plan_id to the user object which was just created..

Thanks

Ninja Boy
  • 1,112
  • 3
  • 14
  • 28
  • Possible duplicate of [Override devise registrations controller](http://stackoverflow.com/questions/3546289/override-devise-registrations-controller) – Eyeslandic May 06 '17 at 17:39

1 Answers1

0

As per the answer here, override the controller and set routes. Then in the create action,

def create
  super do |resource|
    resource.update_attribute(:plan_id, params[:plan_id])
  end
end
Community
  • 1
  • 1
Md. Farhan Memon
  • 6,055
  • 2
  • 11
  • 36