Project

a_a_n

0.0
No commit activity in last 3 years
No release in over 3 years
Whenever you need assign an association by its attribute, like name, this gem comes to business.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.1.3
~> 1.6.4
>= 0
~> 0.9.2
~> 1.0.0
>= 0
~> 0.6.4
~> 0.6.0
 Project Readme
Structure:

    class UserProfile < ActiveRecord::Base

      belongs_to :home_country, :class_name => 'Country'
      belongs_to :current_university, :class_name => 'University'

      acts_as_aan do
        association :current_university do
          [:name]
        end
        association :home_country do
          [:name, { :iso_3166_a2 => :country_code}]
        end
      end

      validates :home_country, :presence => true
      validates :current_university, :presence => true
    end

Usage:

    u = UserProfile.new
    u.home_country_name = 'Netherlands'
    u.current_university_name = 'University Of Amsterdam'
    u.save # => true

    u.home_country # => #<Country id: 12, name: "Netherlands"
    u.home_country_name # => "Netherlands"