Sha256: 150bb415803fefc5f5096721420b9f6ba75f70e29df49d11ccc0859bb0199f63
Contents?: true
Size: 978 Bytes
Versions: 4
Compression:
Stored size: 978 Bytes
Contents
class Content < ActiveRecord::Base # ADJUST_POSTIONS DOES NOT WORK RIGHT NOW # before_save :adjust_positions class << self; attr_accessor :tipes; end @tipes = [ # "Billboard", # "What You Learn", # "Tips", # "Questions Copy", # "FAQ", # "Examples", # "Testimonial", # "Navigation", ] @tipes.each do |thing| scope "for_#{thing.downcase.gsub(' ', '_')}".intern, where("tipe = ?", thing) end scope :visible, lambda {|x| where(:visible => x)} def brothers Content.where("tipe = ?", self.tipe).where("id NOT in (#{self.id})") end private def adjust_positions # return true unless changed.include?('position') # # @contents = brothers.order('position ASC') # @contents.each_with_index do |x, idx| # unless x.position > self.position # if x.position # x.update_attribute :position, x.position + 1 # else # x.update_attribute :position, self.position + idx # end # end # end end end
Version data entries
4 entries across 4 versions & 1 rubygems