开发者

get session id from another table

开发者 https://www.devze.com 2023-02-20 18:27 出处:网络
I have 3 tables--answers, questions and tokens. IN tokens I have id, token, created_at, updated_at. IN answers i have id, token (id), text, created_at, updated_at

I have 3 tables--answers, questions and tokens.

IN tokens I have id, token, created_at, updated_at.

IN answers i have id, token (id), text, created_at, updated_at

In questions - id, text

How can I get ID (from tokens) ? I do this way:

result=Answer.create(:question_id=>question.id,:token=>session[:token],:text=>params["answer_"+question.id.to_s])
开发者_如何学Go

I don't want session[:token], it's pasted in table TOKENS (for example 23709274092107hdjshdsj) and I

just need ID!


It looks as though you're only storing the token in session. So you'd have to get the ID from the token so:

token = Token.find_by_token(session[:token])
result=Answer.create(:question_id=>question.id,:token=>token.id,:text=>params["answer_"+question.id.to_s])
0

精彩评论

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