search for: voteable_id

Displaying 2 results from an estimated 2 matches for "voteable_id".

2009 Nov 09
3
How can I improve a Ruby on Rails code that hast a lot of SQL as strings?
...items` for MySQL but not for other databases. - In the same vein, is there a way to get a field name the same way Rail''s ORM would put it in a SQL query? - Maybe there''s a way to get both, the table name and the field name in one operation. I''m imaging something like Item.voteable_id.for_query => "`items`.`voteable`". - How do I escape code to avoid SQL injection when not in conditions? I''m using the user_id variable directly in a query and although it''s impossible for a user to put anything in it, I''d rather escape it properly. In a cond...
2007 Dec 20
3
ActiveRecords Eager Loading
...pensive query. After indexing, it take about 3 seconds to execute. (before indexing it is about 25 seconds) SELECT DISTINCT articles.id FROM articles LEFT OUTER JOIN assets ON assets.attachable_id = articles.id AND assets.attachable_type = ''Article'' LEFT OUTER JOIN votes ON votes.voteable_id = articles.id AND votes.voteable_type = ''Article''AND user_id = 2 WHERE (assets.parent_id is null) ORDER BY stat_final_ranking desc LIMIT 20 ----------------------------------- so, what I plan to do it is to cache the expensive query without including vote table Article.find(:...