Use AR Extensions for this. It supports the following condition modifiers: lt => less than * _gt => greater than * _lte => less than or equal to * _gte => greater than or equal to * _ne => not equal to * _not => not equal to Now you can rewrite your query as follows: products = Product. Find(:all, :limit => 5, :joins => :tags, :conditions => { :locale => 'en', :id_not => '1', :tags => { :name => 'a','b'} ) Read this article for more details.
Use AR Extensions for this. It supports the following condition modifiers: * _lt => less than * _gt => greater than * _lte => less than or equal to * _gte => greater than or equal to * _ne => not equal to * _not => not equal to Now you can rewrite your query as follows: @products = Product. Find(:all, :limit => 5, :joins => :tags, :conditions => { :locale => 'en', :id_not => '1', :tags => { :name => 'a','b'} ) Read this article for more details.
It should be something like this. The original query wasn't really clear, adapt it to your needs. @products = Product.
Find(:all, :limit => 5, :conditions => "locale =? AND id? AND tags.Name IN (?)", "en", 1, 'a','b', :joins => "tags" ).
1 I'm looking for "no-string" solution, as hash {...}. – xpepermint Feb 25 '10 at 14:16 1 It doesn't exist a solution using Hash. – Simone Carletti Feb 25 '10 at 15:07.
Another way is to use the merge_conditions which turns the hash conditions into a string. Then you can add on whatever you want or call merge_conditions again with other options. Hash_conditions = {:category => 'computers'} conditions = Product.
Merge_conditions(hash_conditions) + ' AND products. Id NOT IN(1139) ' products = Product. Find(:all, :conditions => conditions).
If you’re used to using raw SQL to find database records, then you will generally find that there are better ways to carry out the same operations in Rails. Active Record insulates you from the need to use SQL in most cases. Active Record will perform queries on the database for you and is compatible with most database systems (MySQL, PostgreSQL and SQLite to name a few).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.