Schema:
action_types
------------
id
name
description
actions
-------
id
action_type_id
date
description
目标是只在用户界面上还没有被占用的情况下,将action\types.description复制到actions.description。.
做了什么:
class ActionsController < ApplicationController
active_scaffold :action do |c|
c.columns = [ \
, :date \
, :action_type \
, :description \
]
c.columns[:action_type].form_ui = :select
c.columns[:action_type].options[:update_column] = :description
c.columns[:description].form_ui = :textarea
c.columns[:description].options = { :cols => 40, :rows => 5}
end
protected
def after_render_field(record, column)
# record: almost empty, only "action_type" is filled.
# column: column.name == "action_type"
# @params[]: id: id for the record
# But no data on UI state. So if the user wrote some lines into the
# description then it will be lost. No possibility
# to express "do nothing!"
end
#...
end
另外,如果我们在“更新”期间仅在“创建”时没有此功能,我可以接受。这是一半,但现在就足够了。
有什么想法吗?
(Rails 2.3.4)