Let\'s say we have the following:
irb> Post.where(:hidden => true).to_sql
=> \"SELECT `posts`.* FROM `posts` WHERE posts.hidden = 1\"
In rails 4 there is not
suffix for this purpose:
Post.where.not(hidden: true).to_sql
# => SELECT FROM `posts` WHERE `posts`.`hidden` != 1
In rails 3 you can use squeel gem. It gives many usefull features. And with it you can write:
Post.where{ hidden != true }.to_sql
# => SELECT FROM `posts` WHERE `posts`.`hidden` != 1