Conditional search in Ruby On Rails
For Conditional search in ror
I have the following model:
create_table "users", :force => true do |t|
t.string "name"
t.string "url"
t.integer "clicks_given"
t.integer "clicks_received"
t.datetime "created_at"
t.datetime "updated_at"
end
and I have defined this method for the model:
def credits
credits = self.clicks_given - self.clicks_received
end
Pass the condition as an array instead of a hash:@users = User.find(:all, :conditions => [ "clicks_given - clicks_received >= ?", -5 ])
Comments
Post a Comment