move swag fields to partial

This commit is contained in:
nasia 2017-08-25 20:04:19 +03:00
parent 93f7e07ebe
commit e55509183c
5 changed files with 21 additions and 23 deletions

View file

@ -3,11 +3,20 @@ class Sponsor < ActiveRecord::Base
belongs_to :conference
serialize :swag_hash, Hash
attr_accessor :type, :quantity, :swag_index
attr_accessor :type, :quantity, :swag_index, :hint_hash
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
mount_uploader :picture, PictureUploader, mount_on: :logo_file_name
validates :name, :website_url, :sponsorship_level, presence: true
def generate_swags_hash(type, quantity)
unless swag_hash
swag_hash = {}
end
swag_hash[type.to_s] = quantity.to_i
update_attribute(:swag_hash, @sponsor.swag_hash)
end
end