I wanted to know how we could store the result of my select query on a variable.
@ppt2 = Ppt.select('slide_name').where('id=?',4)
@ppt1 = Ppt.update_all({:time2=>@ppt2},['id like ?','1'])
Here, slide_name
and time2
are both text attributes of the same table ppt
.
What happens on the above execution is that the time2
field in id=1
gets the value " @ppt2
" whereas I want it to get the value of slide_name
from id=4
which does not get stored in @ppt1
.
In other words, how do I store the value of the select query in @ppt2
so that it can be used in the next line?
Any help is appreciated.
在第一个结果上调用slide_name
方法。
@ppt2 = Ppt.select('slide_name').find(4).slide_name
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.