开发者

How to pass a variable in Devise sign_up link

开发者 https://www.devze.com 2023-03-06 13:36 出处:网络
How can I pass a variable to my sign_up controller using Devise? I want to add the user开发者_StackOverflow中文版 chosen plan to the database on registration.

How can I pass a variable to my sign_up controller using Devise? I want to add the user开发者_StackOverflow中文版 chosen plan to the database on registration.

Thanks


You can add this in your routes.rb

match 'register' => redirect('/users/sign_up?plan=pro')

OR

match 'register/:plan' => redirect('/users/sign_up/{%plan}')

And create the matching controllers.

Get more routes info from here: http://guides.rubyonrails.org/routing.html#redirection

Alternatively, this can also be used https://github.com/plataformatec/devise/wiki/How-To:-Customize-routes-to-user-registration-pages

0

精彩评论

暂无评论...
验证码 换一张
取 消