Forum: Ruby on Rails Model with file uploads

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
John (Guest)
on 2006-04-13 17:55
I'm working on a model for a videos table that include the video info
(title, description) and a couple of uploads (video file, thumb image)
I was going to use the file_column plugin but I dont like the idea of
storing the file names in the database when I dont need to, plus I dont
think it is very flexible.

Here's what I done. What do you think of this? Any suggestions?

class Video < ActiveRecord::Base

  attr_accessor :field_tags
  attr_accessor :field_thumb
  attr_accessor :field_video

  validates_presence_of :title
  validates_presence_of :description
  validates_presence_of :field_tags

  def validate_on_create
    errors.add 'field_thumb', 'Invalid thumb' unless
    errors.add 'field_video', 'Invalid video' unless

  def after_create
    self.tag_with self.all_tags

    # upload field_video and upload field_thumb

  def after_update
    self.tag_with self.all_tags

  def after_delete
    # delete video and thumb files

  def tags
    # return formatted tags from tag_list

  def thumb
    # return full thumb url

  def video
    # return full video url
This topic is locked and can not be replied to.