在submit操作中(从我的标准RoR编辑视图),我希望将现有数据字段作为正在进行的文本转储存储在同一行中。
控制器应该将数据字段(例如current_location
)的值“推”到表字段logdump
中的text
,并使用\n
作为分隔符。
经过一些旅行和"current_location“的更改,将会有例如以下文本存储在表字段logdump
中:London Rio Athen Berlin New York
我考虑将这个日志存储在一个额外的日志表中,但是这个字符串转储到我现有的表中的解决方案已经足够满足我的需要了。
发布于 2016-08-20 17:42:19
你可能需要序列化它
class User < ActiveRecord::Base
serialize :current_location, Array
end
u = User.new
#=> #<User id: nil, current_location: [], created_at: nil, updated_at: nil>
u.current_location = %w(London Rio Athen Berlin New\ York)
u.save
https://stackoverflow.com/questions/39052098
复制相似问题