This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# db/migrate/#{timestamp}_add_owner_to_delayed_jobs | |
class AddOwnerToDelayedJobs < ActiveRecord::Migration | |
def self.up | |
add_column(:delayed_jobs, :owner_type, :string) | |
add_column(:delayed_jobs, :owner_id, :integer) | |
end | |
def self.down | |
remove_column(:delayed_jobs, :owner_type) | |
remove_column(:delayed_jobs, :owner_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module NullifyBlankAttributes | |
def write_attribute(attr_name, value) | |
new_value = value.presence | |
super(attr_name, new_value) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Video < ActiveRecord::Base | |
validates_presence_of :title | |
named_scope :finished, :conditions => { :encoded_state => "finished" } | |
has_attached_file :video, | |
:url => ":class/:id/:style/:basename.:extension", | |
:path => ":class/:id/:style/:basename.:extension", | |
:storage => :s3 | |
validates_attachment_presence :video |
NewerOlder