スキーマ:
action_types
------------
id
name
description
actions
-------
id
action_type_id
date
description
目標は、action_types.description を actions.description にコピーすることです (UI でまだ使用されていない場合のみ) (!)。
行われること:
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
または、「作成」でのみ「更新」中にこの機能がない場合は、受け入れることができます。これは半分の測定値ですが、今のところ十分です。
何か案は?
(レール 2.3.4)