Checking for duplicates with nested forms
Posted
by
Cyrus
on Stack Overflow
See other posts from Stack Overflow
or by Cyrus
Published on 2012-12-14T23:01:55Z
Indexed on
2012/12/14
23:03 UTC
Read the original article
Hit count: 178
ruby-on-rails-3
|nested-forms
I'm making a rails 3.2.9 app that allows users to create pages and they can embed youtube videos through a nested form.
I'm trying to figure out how to make it so that I can prevent duplicate video records from being stored in my db.
So I have a Video model that takes the youtube url and just parses out the video id and stores that instead of the full user submitted youtube url, which may have extraneous url query parameters.
So here's the situation that I'm trying to figure out:
There's page1
with video1 - url: 123
and video2 - url: abc
Then another user creates page2
and submits video3 - url: def
and video4 - url: 123
Currently each page has_many videos. But I think I should change it to a many-to-many relationship. But how would I make it so that the url submitted as video4
in the nested form points to video1
?
Also I how would I make a nested form that creates objects that are connected through a join table?
© Stack Overflow or respective owner