Rails relations
problem
You know when you want to select records depending on the values of related records (like belongs_to fields) ?
scenario
class TradingSignal < ActiveRecord::Base belongs_to :product end
class Product < ActiveRecord::Base has_many :trading_signals, :dependent => :destroy end
Great way of getting all TradingSignals where its related product are one of the given ID’s
TradingSignal.joins(:product).where(:products => {:id => ids})