globalize/globalize — pull request #328 by scarfacedeb (2014-02-04 11:19:54+00:00)
Title: Don't create translation record for default_locale on save

I want to allow users to create localized pages for a specific locale, excluding default locale.
That way I can have a czech-specific page only on the czech version of a site.
But I can't do that because when I'm trying to save a new `Page` record with a `Page::Translation` association (`locale == :cz`), rails gives me a validation error, because globalize has added another association with `locale == :en`.

I'm using `rails_admin` and its default field for has_many associations.

I think that my problem starts inside `save` method.
```ruby
def save(*)
Globalize.with_locale(read_attribute(:locale) || I18n.default_locale) do
super
end
end
```
In particular, this part in `read_attribute`:
```ruby
if name == :locale
self.try(:locale).presence || self.translation.locale
```
Which leads to `translation` method:
```ruby
translation_for(::Globalize.locale)
```

As a result, `translation_for` builds an empty translation for default `::Globalize.locale` locale.

---------------

I think that `read_attribute(:locale)` could skip creating default translation record, because in that particular case it only uses it to get its locale, that is equal to `Globalize.locale` anyway.
I ran `rake test` on this branch and on the branch with merged *before_callbacks* (it's called *combined*) and there's no new errors.