Forum: Ruby on Rails Duplicates

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9054a70a5ebc5824bc2a0b5465e7b342?d=identicon&s=25 tmatsumoto (Guest)
on 2005-11-26 12:24
(Received via mailing list)
i'd gone through the tutorial in agile web dev for building an
application and i noticed for the user table, if you entered the same
user a new id would be assigned and the name would be duplicated. in
other programming experience i'd keep the user table with no
duplicates, but still use the existing id in join tables.

for instance a table of authors. that would have no duplicates, but
each time an article of an author was written the existing authors id
would be assigned to the article id in a join table.

is there a validation method or a similar process for doing this in
rails?

Todd
0bcc972918891ef358b0b3dfb4e7f18b?d=identicon&s=25 hammed (Guest)
on 2005-11-26 15:49
(Received via mailing list)
You can enforce unique users in your table using
'validates_uniqueness_of'.

http://api.rubyonrails.com/classes/ActiveRecord/Va...

Hammed
This topic is locked and can not be replied to.