Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
association_as_name
Ruby
tag: v0.1.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.rspec
Gemfile
README
Rakefile
a_a_n.gemspec
init.rb

README

Structure:

    class UserProfile < ActiveRecord::Base

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

      acts_as_aan do
        [ [:current_university, 'University', :name],
          [:home_country, 'Country', :name]]
      end

      validates :home_country_name, :presence => true
      validates :current_university_name, :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"
Something went wrong with that request. Please try again.