Reputation: 95
In my rails app, I have a product category. Each product can have multiple videos(from Youtube or vimeo).
I have generated a model and migration with following columns
:title, :description, :video_link, :product_id
I would like to show only one video on the product display page as a main or primary video and the rest videos on "details on product" page.
/product.rb
has_many :video_links, dependent: :destroy
/video_link.rb
belongs_to :product
So my question is, how should I approach to mark one video to display on the product front page (view) and the rest videos for details page?
Upvotes: 0
Views: 44
Reputation: 27789
how should I approach to mark one video to display on the product front page (view) and the rest videos for details page?
That depends on what you want a "front page video" to mean.
updated_at
column and pick the video with the largest value.In other words it looks like at this stage this is a design rather than a coding issue.
Upvotes: 1
Reputation: 19
You can have another column that is something like "main_video" on the "video_links" table that is a boolean and just display that one whenever you need to grab just one.
Upvotes: 1