0

Rails v2.3.8

formtastic v1.1.0

Forms draw correctly, validation works, but the validation messages for anything involving the length of a string are showing up as:

is too short (minimum is {{count}} characters)

Basically {{count}} is not getting filled in. In irb, I can see that the value is in the @options of the ActiveRecord::Errors:

>> u.errors
=> #<ActiveRecord::Errors:0x7f98785b4ab0 @errors=#<OrderedHash {"password"=>[#<ActiveRecord::Error:0x7f9878561b30 @type=:too_short, @options={:default=>nil, :count=>4},...

Note that this is a validation on a User model being performed by authlogic v2.1.6 (which may not be relevant).

--- UPDATE --------- :

After some more digging, I copied the en.yml locale file out of the activerecord-2.3.8 gem dir and into my local app config/locales dir. After changing all the {{count}} to %{count} things are now displaying properly.

Maybe a bug with formtastic v1.1.1 working with rails v2.3.8? The changelog speaks to a few things generally that it could possibly fall under. There are several newer versions of formtastic available. I unfortunately cannot upgrade this environment so I am going to setup another to test the newer formtastic versions.

4

1 に答える 1

0

{{count}}や{{model}}、{{attributes}}などを表示するメッセージは最近よく見られますが、サーバーにRails3アプリがインストールされていることが原因である可能性もあります。

一般的な修正がいくつかあります。

1)2.3.8から2.3.9または2.3.10にバンプアップします。非常に小さな変更であり、他には何の影響もありません(もちろんテストですが)。したがって、environment.rbでRailsのバージョンを変更するだけです。

2)バージョン固有のil8nのgem(例:(0.4.2))をenvironment.rbに含め、次の行を追加します。

gem il8n、:version => '0.4.2'

bundlerも大いに役立ちます。Rails3では標準ですが、既存の2.3.xアプリを変更して使用するための手順(通常は知っておく必要があることではありませんか?)は次のとおりです。まあ、明らかにそれをインストールします、おそらく。次に、gem install bundlerは、environment.rbファイルから既存のすべての「gem ...」ステートメントを取得して(最終的にはそこで削除し)、Gemfileに配置します。次に、bundleinstallまたはbundleupdateのようなコマンドを使用して、「bundle」を作成できます。 。上記のコマンドは、使用しているバージョンを持つGemfile.lockを作成します。

また、複数のキュウリバージョンがある場合、またはIDEで実行されているテストの問題がある場合は、次のコマンドが必要になる場合があります:bundle exec cucumber features/user_can_login.featureまたはbundleexeccucumber features / user_can_login.feature:6(特定の行番号)。

于 2011-02-24T03:09:20.710 に答える