All Projects → pedrofurtado → rails-countries

pedrofurtado / rails-countries

Licence: MIT license
Integration between Rails and countries gem.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to rails-countries

Active reporting
OLAP-like DSL for ActiveRecord-based reporting
Stars: ✭ 83 (+388.24%)
Mutual labels:  activerecord, gem
Datagrid
Gem to create tables grids with sortable columns and filters
Stars: ✭ 921 (+5317.65%)
Mutual labels:  activerecord, gem
filtered
Filters ActiveRecord queries in a nice way
Stars: ✭ 28 (+64.71%)
Mutual labels:  activerecord, gem
rails cursor pagination
Add cursor pagination to your ActiveRecord backed application
Stars: ✭ 21 (+23.53%)
Mutual labels:  activerecord, gem
active record-updated at
Touch `updated_at` by default with calls to `update_all` and `update_column(s)`
Stars: ✭ 27 (+58.82%)
Mutual labels:  activerecord, gem
Graphql devise
GraphQL interface on top devise_token_auth
Stars: ✭ 100 (+488.24%)
Mutual labels:  activerecord, gem
Algoliasearch Rails
AlgoliaSearch integration to your favorite ORM
Stars: ✭ 352 (+1970.59%)
Mutual labels:  activerecord, gem
Counter culture
Turbo-charged counter caches for your Rails app.
Stars: ✭ 1,397 (+8117.65%)
Mutual labels:  activerecord, gem
index shotgun
duplicate index checker 🔥 🔫 👮
Stars: ✭ 35 (+105.88%)
Mutual labels:  activerecord, gem
activerecord-shard for
Database Sharding Library for ActiveRecord
Stars: ✭ 16 (-5.88%)
Mutual labels:  activerecord, gem
rails async migrations
Asynchronous support for ActiveRecord::Migration
Stars: ✭ 56 (+229.41%)
Mutual labels:  activerecord
secs4java8
This library is SEMI-SECS-communicate implementation on Java8.
Stars: ✭ 46 (+170.59%)
Mutual labels:  gem
zen-query
parascope gem for param-based scope generation
Stars: ✭ 25 (+47.06%)
Mutual labels:  activerecord
models stats
Charts for your rails models with MetricsGraphics.js and NVD3
Stars: ✭ 43 (+152.94%)
Mutual labels:  activerecord
geo-sql-database
Continents, Sub-Continents, Countries, States, Cities, Timezones, Currencies SQL database.
Stars: ✭ 30 (+76.47%)
Mutual labels:  countries
zapier-REST-hooks
Rails engine that provides all the functionality/structure for Zapier REST hooks pattern.
Stars: ✭ 23 (+35.29%)
Mutual labels:  gem
china regions
Ruby Library for China Regions
Stars: ✭ 23 (+35.29%)
Mutual labels:  countries
defaults
Add default value for ActiveRecord attributes
Stars: ✭ 16 (-5.88%)
Mutual labels:  activerecord
sixarm ruby unaccent
SixArm.com » Ruby » Unaccent replaces a string's accented characters with ASCII characters.
Stars: ✭ 15 (-11.76%)
Mutual labels:  gem
wp-activerecord
An ActiveRecord implementation for WordPress
Stars: ✭ 19 (+11.76%)
Mutual labels:  activerecord

rails-countries

Integration between Rails and countries gem.

Gem Version Gem license

Installation

Add this line to your application's Gemfile:

gem 'rails-countries'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails-countries

Usage

ActiveRecord models

class Person < ActiveRecord::Base
  validates :my_attribute, countries_alpha2: true
  # or
  validates_countries_alpha2_of :my_attribute

  validates :another_attribute, countries_alpha3: true
  # or
  validates_countries_alpha3_of :another_attribute
end

Plain Old Ruby Objects

class Person
  include ActiveModel::Model

  validates :my_attribute, countries_alpha2: true
  # or
  validates_countries_alpha2_of :my_attribute

  validates :another_attribute, countries_alpha3: true
  # or
  validates_countries_alpha3_of :another_attribute
end

Views

Helpers

<%= i18n_country_name_by_alpha2('US') %>
<%= i18n_country_name_by_alpha2('US', 'pt-BR') %>

<%= i18n_country_name_by_alpha3('USA') %>
<%= i18n_country_name_by_alpha3('USA', 'pt-BR') %>

Rails Form helpers

<%= select_tag(:my_attribute, countries_alpha2_options) %>
<%= select_tag(:my_attribute, countries_alpha2_options('pt-BR')) %>

<%= select_tag(:another_attribute, countries_alpha3_options) %>
<%= select_tag(:another_attribute, countries_alpha3_options('pt-BR')) %>

SimpleForm

<%= f.input :my_attribute, collection: countries_alpha2_options %>
<%= f.input :my_attribute, collection: countries_alpha2_options('pt-BR') %>

<%= f.input :my_attribute, collection: countries_alpha3_options %>
<%= f.input :my_attribute, collection: countries_alpha3_options('pt-BR') %>

I18n

To customize your error messages you can create a locale file like this:

en:
  errors:
    messages:
      countries_alpha2_invalid: '%{alpha2} is not valid'
      countries_alpha3_invalid: '%{alpha3} is not valid'

Contribute it!

Help us to improve the features and translations of this gem! Your contribution will be welcome 🎉

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].