Monday, July 21, 2014

Using activerecord to find associated models

Let say I have two Model like below

class Plan < ActiveRecord::Base
    has_many :clients


class Client < ActiveRecord::Base
    belongs_to :plan


 For example I wanted to find all clients which has a plan_id = 5, here is the code
clients = Client.all( :include => :plan, :conditions => [ 'plan_id=?', 5 ] )


Anonymous said...

The King Casino: Get a $500 Bonus -
The King Casino was designed to 더킹카지노 cater to every player. It is an exciting destination for players with the ミスティーノ possibility to choose a game from any

Unknown said...

Air Jordan 6'9 Double-Edge Razor - Jordan6Retro
Compare prices and find an air jordan 18 retro red cheap amazing price for the Air Jordan how can i get air jordan 18 stockx 6'9 Double-Edge Razor. (United air jordan 18 retro men blue from me States) at a air jordan 18 retro red suede from me low price. Compare the top-rated what is the best air jordan 18 retro men brands