I have 2 tables I need to join but the user_id column value is not the same in both tables. So I want to do something like this:
In my controller 4
will be substituted with current_user.id
select * from sites join pickups on sites.id = pickups.site_id where sites.user_id = '4'
But using an ActiveRecord Find.
Here are my associations:
class Site < ActiveRecord::Base
belongs_to :user
has_many :pickups
class Pickup < ActiveRecord::Base
belongs_to :site
belongs_to :user
class User < ActiveRecord::Base
has_one :profile
has_many :pickups
has_many :sites
Thanks in advance!