开发者

Devise sign in and registration forms from somewhere else in my app

开发者 https://www.devze.com 2023-04-01 01:35 出处:网络
I am building an e-commerce style site which lists products that you can buy. When you click on buy it takes you through to a URL like: http://shopfront.com/deal/123/buy.

I am building an e-commerce style site which lists products that you can buy. When you click on buy it takes you through to a URL like: http://shopfront.com/deal/123/buy.

I would like to provide Devise sign up and sign in on that buy page. I can currently get users to sign up and upon a successful sign up they will be redirected back to my buy page for the item they are interested in but if they provide insufficient details开发者_如何学编程, they get redirected to devise's default sign up form which displays the error they encountered. Afterwards they are no longer redirected to my buy page and instead end up on the home page.

I have my own registrations controller which is where I am doing the redirect back to the relevant buy page on successful sign ups but I cannot figure out how to redirect unsuccessful sign ups back to the buy page.

I need to implement more or less the same functionality for a sign in form which will be displayed next to the sign up form on that same buy page. Any assistance would be appreciated.


Nice way is to store client state in session

put something like,

session[:return_to] = request.fullpath

in your controller, you may like to put this in private method

In general "in session", means to store data in cookies, as session store points by default to

Rails::Application.config.session_store

=>

ActionDispatch::Session::CookieStore
0

精彩评论

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

关注公众号