Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shioyama/mobility-ransack
Search attributes translated by Mobility with Ransack
https://github.com/shioyama/mobility-ransack
i18n rails ransack ruby translation
Last synced: 19 days ago
JSON representation
Search attributes translated by Mobility with Ransack
- Host: GitHub
- URL: https://github.com/shioyama/mobility-ransack
- Owner: shioyama
- License: mit
- Created: 2018-09-12T03:39:32.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T06:48:14.000Z (over 1 year ago)
- Last Synced: 2024-10-14T00:27:08.434Z (about 1 month ago)
- Topics: i18n, rails, ransack, ruby, translation
- Language: Ruby
- Size: 70.3 KB
- Stars: 28
- Watchers: 3
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Mobility Ransack
================[![Gem Version](https://badge.fury.io/rb/mobility-ransack.svg)][gem]
[![Build Status](https://github.com/shioyama/mobility-ransack/workflows/CI/badge.svg)][actions]
[![Code Climate](https://api.codeclimate.com/v1/badges/2494f02bcd6b65a545fa/maintainability.svg)][codeclimate][gem]: https://rubygems.org/gems/mobility-ransack
[actions]: https://github.com/shioyama/mobility-ransack/actions
[codeclimate]: https://codeclimate.com/github/shioyama/mobility-ransackSearch on translated attributes with
[Mobility](https://github.com/shioyama/mobility) and
[Ransack](https://github.com/activerecord-hackery/ransack).## Installation
Just add the gem to your Gemfile:
```ruby
gem 'mobility-ransack', '~> 1.2.2'
```Now enable the `ransack` plugin in Mobility's configuration:
```ruby
Mobility.configure do
plugins do
ransack# ...
end
end
```This will enable the ransack plugin for all models. Disable it by passing
`false` to the `ransack` option:```ruby
class Post < ApplicationRecord
extend Mobility
translates :foo, ransack: false
end
```You can search on `foo` with Ransack just like any untranslated attribute, e.g.
if `Post` has a `title` attribute translated with the Jsonb backend:```ruby
Post.ransack(title_cont: "foo").result
#=> SELECT "posts".* FROM "posts" WHERE ("posts"."title" ->> 'en') ILIKE '%foo%'
```Other backends work exactly the same way.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).