Thank you for your reply Balaji and Raul. I will try that out and let you know, if it worked for my problem.
Yes i think Balaji is correct. I'll expand on that an say it should be something like this:
validates_uniqueness_of :kompid, :assign_month, :assign_year :scope => [:kompid, :assign_month, :assign_year], :message => â€œXXXXXXXXâ€
That might do what you want. I hope :)
If i am not wrong you can use the :scope option in your validation
:scope => :assign_month,<br /> :message => "^XXXXXXXX"
could someone help me with a validation question i have ?
I am importing data from a .csv-file into my database via FasterCSV (http://fastercsv.rubyforge.org/). Now, while reading the data into my database, the user will be able to assign "month" and "year" to the data.
The migration looks like this:
create_table :imodhwdbs, :force => true do |t|
t.column :kompid, :string, :limit => 8 . . . t.column :assign_month, :string, :limit => 8 t.column :assign_year, :string, :limit => 4
How would i write a validation to check for the combination :kompid, :assign_month and :assign_year to be unique in the database. If there is another combination of those entries already in place, i could throw an error, but how do i check the uniqueness of this combination ?