wingedmonkey/wingedmonkey — pull request #77 by jtomasek (2012-12-21 14:16:19+00:00)
Title: Adding validations and initial rails i18n configuration

I have added support for validating forms for provider_application model. As it is not activerecord model it is necessary to make it ```extend ActiveModel::Callbacks```.

Then I wanted the model to get validated before running the ```save``` method:
```
define_model_callbacks :save
before_save :valid?
```

in subclass (eg. MockProviderApplication) then put the contents of ```save``` method into run_callbacks block:
```
def save
run_callbacks :save do
#save method content
end
end
```

with this set up, you can include validations call into either ProviderApplication or ProviderApplication.

eg. ```validates :name, :presence => true```

see https://github.com/rails/rails/blob/master/activemodel/lib/active_model/callbacks.rb for more info.

note: right now the validation error messages go to the same place as all notifications. Keep in mind that after alchemy receives simple_form functionality, we'll get the error messages next to the input fields for free.

--------

Second patch brings initial rails i18n setup. I created three translation files:
- default: carries rails default translations for dates, errors etc. (https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/en.yml)
- activerecord: carries activerecord model and attribute names translation
- activemodel: carries non-activerecord model and attribute names translations
use these everytime you need to translate the model or it's attribute. Don't create new translations when not necessary.

```config/locales/en.yml``` should carry all the translations which don't fit into the activerecord or activemodel or aren't already included in defaults.

I am introducing this patch even though we didn't decide whether to use gettext or rails i18n but as I am familiar with rails i18n, when we'll decide to go the gettext way, I'll then know what I want to replace and what functionality/structure I want to achieve.