Created
April 29, 2015 00:54
-
-
Save c80609a/f31042c09bd56ba152ca to your computer and use it in GitHub Desktop.
activeAdmin, carrierwave, has_many files, reject_if attributes NOT present, allow_destroy
This file contains 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/c80609a/e64ff4f3dcc7ee8a2b86