Rails3とmongoidを使用しています。
別のレコードの値に基づいて、あるレコードの値を保存または更新したい。
例えば:
class User
include Mongoid::Document
field :account_level, :type => Integer
end
class Profile
include Mongoid::Document
field :position, :type => Integer
end
account_levelin Userが1の場合、positioninProfileも1に更新する必要があります。account_level is 2, then位置`が2である必要がある場合。
これは、ユーザーからの入力なしで、またはクライアントの非表示の入力フィールドを使用してプログラムで実行する必要があります(それよりも優れた方法が必要です)。
追加の質問...私は次のロジック(のためにposition)を持っていました、これをどのように行うのですか?
account_level1 = position1
account_level2 = position1
account_level3 = position5