I have the following code:
class Like < ActiveRecord::Base
belongs_to :site
validates_uniqueness_of :ip_address, :scope => [:site_id]
end
What deprives a person of "loving" a site more than once based on a remote ip-request. In fact, when someone “loves” the site, the record is created in the Likes table, and I use a hidden field to query and pass my IP address to the column: ip_address in a similar table. With the code above, I restrict the user to one “similar” to their IP address. I would like to limit this to a specific number, for example 10.
My initial thought was as follows:
validates_uniqueness_of :ip_address, :scope => [:site_id, :limit => 10]
But that does not work. Is there any simple syntax here that will allow me to do this?