This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/87

in_place_editor_fieldとかを使っていると、属性ごとに個別に妥当性検証を行いたい時がありますね。 そんなわけで、Modelの特定の属性(Attribute)だけ妥当性を検証する方法のメモです。

model[attribute] = some_value
if !model.valid? && model.errors.invalid?(attribute)
  # specified attribute is invalid!
end
あとは、in_place_editor_fieldもerrorsの中身をチェックして赤くなったり、メッセージを出したりしてくれると良いんですけど。

This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/87

posted by Png genki on Thu 24 Aug 2006 at 03:00
Contents
Modelの特定の属性だけ妥当性を検証する
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
KingofSmack: Here also good reads for this mobile applicatio... '14-5
Spencer: You don't have to re-compile it, this version w... '14-4
staiano: Any chance we can get a recompile for 10.9? '14-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ