开发者

How to pass a variable in Devise sign_up link

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜