【发布时间】:2012-04-30 14:56:27
【问题描述】:
我正在遍历一个对象列表并更改一些值。当我将值输出到记录器中时,我会看到更改后的值,但是在结果页面上时,更改不会被保存。
这是我的循环:
@dis.each do |d|
temp = d.notes.inspect
#Now check the length of the temp variable
temp.length > 25 ? temp = temp[0,25] : nil
d.notes = temp
end
如何更改它以便将 temp 的新值保存在 @dis 对象中?
谢谢!
【问题讨论】:
-
@fl00r 视图有点意大利面,但为什么循环不够代码?不能只用新值重置对象吗?
标签: ruby-on-rails ruby