Guest User

Untitled

a guest
May 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. ## in a controller:
  2. # Is there a cleaner way of expressing this:
  3. @contracts = Contract.find( @user.facilities.map{|f| f.contract_id } )
  4.  
  5. # User: has_many => :facilities, :through => :user_facilities
  6. # Contracts: has_many => :facilties & facilites belongs_to Contracts
  7.  
  8. # I'd like to do something like: @user.facilities.contracts, but there doesn't seem to be a way to do this in Rails
Add Comment
Please, Sign In to add comment