scaffoldのfieldWithErrosでselectが赤くならないよ??
自分だけなんだろうか??
プルダウンのエラーで赤い枠が出ないぞ。
http://capsctrl.que.jp/kdmsnr/diary/20060414.htmlをenvironment.rbにコピペして修正した。
module ActionView class Base @@field_error_proc = Proc.new{ |html_tag, instance| "<span class=\"fieldWithErrors\">#{html_tag}</span>" } cattr_accessor :field_error_proc end end
それからエラー表示がランダムなのも困る。これはエラーチェック対象をhashで持っているから
http://d.hatena.ne.jp/elm200/20070819/1187477042を参考に下記をenvironment.rbに追記して解決。
module ActiveSupport class OrderedHash def each_key each { |key, value| yield key } end end end module ActiveRecord class Errors def initialize(base) # :nodoc: @base, @errors = base, ActiveSupport::OrderedHash.new end def clear @errors = ActiveSupport::OrderedHash.new end end module Validations module ClassMethods def write_inheritable_set(key, methods) existing_methods = read_inheritable_attribute(key) || [] write_inheritable_attribute(key, existing_methods | methods) end end end end