search for: produceselect

Displaying 1 result from an estimated 1 matches for "produceselect".

2013 Jun 15
1
A puzzle about default_scope
...has_many :blogs default_scope where(deleted_at: nil) end class Blog < ActiveRecord::Base belongs_to :user end I want to produce sqlselect blogs.* from blogs inner join users on users.id = blogs.user_id and users.deleted_at is null And the code Blog.joins(:user), which I think is good, produceselect blogs.* from blogs inner join users on users.id = blogs.user_id The default_scope is not appended to the join condition, why? To reach my goal, I must add conditions to belongs_to: class Blog < ActiveRecord::Base belongs_to :user, conditions: "deleted_at is null" end Why not app...