Skip to content

Instantly share code, notes, and snippets.

View saadbinakhlaq's full-sized avatar
🕴️
up

Saad saadbinakhlaq

🕴️
up
View GitHub Profile
@saadbinakhlaq
saadbinakhlaq / attachment.rb
Created May 21, 2016 08:52 — forked from madwork/attachment.rb
Polymorphic attachments with CarrierWave and nested_attributes
class Attachment < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader
# Associations
belongs_to :attached_item, polymorphic: true
# Validations
validates_presence_of :attachment
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8