开发者

Saving form values to database after a user logs in

开发者 https://www.devze.com 2023-01-03 21:29 出处:网络
We have a form with ratings to submit for a certain restaurant. After the user has entered some values and wants to submit them, we check whether the user is logged in or not. If not, we display a log

We have a form with ratings to submit for a certain restaurant. After the user has entered some values and wants to submit them, we check whether the user is logged in or not. If not, we display a login form and let the user put in his account data and redirect him to the restaurant he wanted to submit a rating for. The problem is, that after he successfully logged in himself, the submitted values are not saved to the database (which works fine if the user is already logged in). So I wondered if it is possible, to somehow save the data although the user is not logged in. I thought of maybe saving the filled values in a variable and have then automatically re-entered after we redirected the user. But I guess this wont work because we use

before_filter :login_required, :only => [ :create ]

So we couldnt even access the filled in values, since we display the login-form before the method has processed the values in the form, right?

Any idea how we can make rails to save the values or at least have them automatically re-entered开发者_运维技巧 to the form?

Thanks!


I would consider an AJAX solution here. Present the login option on the same page without redirecting.

0

精彩评论

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