0
votes

I have a Rails 3.1.1 Project using the Gem ActiveFrom an extension of ActiveModel to validate non persistant models. In my i18n yml File I have the following Code:

activemodel:
  attributes:
    contact_form:
      name: "Name"
      phone: "Telefon"
  errors:
    models:
      contact_form:
        attributes:
          name:
            blank: "Sie müssen Ihren Namen angeben."
          phone:
            blank: "Sie müssen eine Telefonnummer angeben." 

When I get all error messages with @contact_form.errors.full_messages in my view the messages are translated but the attributes not, like:

Phone Sie müssen eine Telefonnummer angeben.

Phone should be translated to Telefon too.

When I do the same thing with persistent models and ActiveRecord this is working? Can anyone tell me the difference from ActiveRecord and ActiveModel in attribute translation?

1

1 Answers

0
votes

After some research I found the problem. It was a bug in ActiveFrom that did not use the i18n translations. I have fixed that and created a new gem rails3-active_form

You can find it at https://rubygems.org/gems/rails3-active_form.

Than add this line to your Gemfile:

gem "rails3-active_form", "~> 2.0.0"

And this to your models:

require "active_form"

class ContactForm < ActiveForm
  attr_accessor :name, :email, :contact_number, :address, :purpose

  # ...
end