Skip to content

Commit

Permalink
Add chapter about limitations #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin B committed Oct 20, 2016
1 parent 4194880 commit 0a6ed3c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,21 @@ Page.create!(:title_en => 'Another English title', :title_de => 'Noch ein Deutsc
Page.where(title: 'Another English title') # => Page
```

### Limitations
`awesome_hstore_translate` patches ActiveRecord, which create the limitation, that a with `where` chained `first_or_create` and `first_or_create!` **doesn't work** as expected.
Here is an example, which **won't** work:

``` ruby
Page.where(title: 'Titre français').first_or_create!
```

A workaround is:

``` ruby
Page.where(title: 'Titre français').first_or_create!(title: 'Titre français')
```

The where clause is internally rewritten to `WHERE 'Titre français' = any(avals(title))`, so the `title: 'Titre français'` is not bound to the scope.

### Upgrade from [`hstore_translate`](https://github.com/Leadformance/hstore_translate)
1. Replace the [`hstore_translate`](https://github.com/Leadformance/hstore_translate) with `awesome_hstore_translate` in your Gemfile
Expand Down

0 comments on commit 0a6ed3c

Please sign in to comment.