Skip to content

Instantly share code, notes, and snippets.

@c80609a
Created April 29, 2015 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c80609a/f31042c09bd56ba152ca to your computer and use it in GitHub Desktop.
Save c80609a/f31042c09bd56ba152ca to your computer and use it in GitHub Desktop.
activeAdmin, carrierwave, has_many files, reject_if attributes NOT present, allow_destroy
require "babosa"
class Suit < ActiveRecord::Base
has_and_belongs_to_many :complects
has_and_belongs_to_many :special_props
has_many :checkins, :dependent => :destroy
has_many :items, :through => :checkins
has_many :suit_photos
accepts_nested_attributes_for :suit_photos,
:reject_if => lambda { |attributes|
# puts "----------------------"
# puts attributes
# puts "----------------------"
# attributes[:filename].blank?
!attributes.present?
},
:allow_destroy => true
extend FriendlyId
friendly_id :title, use: :slugged
def normalize_friendly_id(input)
input.to_s.to_slug.normalize(transliterations: :russian).to_s
end
end
@c80609a
Copy link
Author

c80609a commented Apr 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment