Skip to content

Instantly share code, notes, and snippets.

@nanosplit
Created November 4, 2016 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanosplit/b50241d66947fbcae3a1020d1f94ab8a to your computer and use it in GitHub Desktop.
Save nanosplit/b50241d66947fbcae3a1020d1f94ab8a to your computer and use it in GitHub Desktop.
class Agent < ActiveRecord::Base
has_many :ar_listed, class_name: 'Abor::AborRetsResi', primary_key: 'agent_id', foreign_key: 'list_agent_mlsid'
end
#this lets me do:
@agent_listed_properties = current_agent.ar_listed
#which returns all the listed properties that agent has! Before, I would have had to do something like:
@agent_listed_properties = Abor::AborRetsResi.where(list_agent_mlsid: current_agent.agent_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment