I would like to have substitution+sanitizing features on
:joins.
class Post
belongs_to :user
named_scope :by_admins, {
:joins => 'inner join users as users_for_admin_check on users_for_admin_check.id = posts.user_id'.
:conditions => ['users_for_admin_check.admin = ?', true] }
end
Here I had to move the condition to :conditions, just to get the
? substitution. I need the substitution in this case because
boolean values are handled differently on sqlite/mysql.
In this case I would have liked to keep it all in the join,
since this is actually a join condition.
class Post
belongs_to :user
named_scope :by_admins, {
:joins => ['inner join users as users_for_admin_check on users_for_admin_check.id = posts.user_id and users_for_admin_checking.admin = ?', true]
}
end
I think it doesn't interfere with other stuff, since with the
current behavior, it acts the same as when using symbols in an
array.
at the moment: Using :joins => :symbol will try some inner
join for association named :symbol Using :joins => 'string' will
just put the string in the sql query. Using :joins => [:symbol,
:symbol] will include inner joins for all associations Using :joins
=> ['string', *values] will try the same as with symbols above,
which is inconsistent considering the difference between symbols
and strings without the array.
Any chance this can get implemented? Thanks