Sha256: a8db3fd5d2e4079ebbed2f667f0ea5aeabd19cd45514a99a33db72f969d8b640

Contents?: true

Size: 504 Bytes

Versions: 12

Compression:

Stored size: 504 Bytes

Contents

module Alchemy
	class EssencePicture < ActiveRecord::Base

		acts_as_essence(
			:ingredient_column => :picture,
			:preview_text_method => :name
		)

		belongs_to :picture
		before_save :replace_newlines
		before_save :fix_crop_from

	private

		def fix_crop_from
			write_attribute(:crop_from, self.crop_from.to_s.split('x').map { |number| number.to_i < 0 ? "0" : number }.join('x'))
		end

		def replace_newlines
			return nil if caption.nil?
			caption.gsub!(/(\r\n|\r|\n)/, "<br/>")
		end

	end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
alchemy_cms-2.1.12 app/models/alchemy/essence_picture.rb
alchemy_cms-2.1.11 app/models/alchemy/essence_picture.rb
alchemy_cms-2.1.9.1 app/models/alchemy/essence_picture.rb
alchemy_cms-2.1.9 app/models/alchemy/essence_picture.rb
alchemy_cms-2.1.8.1 app/models/alchemy/essence_picture.rb
alchemy_cms-2.1.8 app/models/alchemy/essence_picture.rb
alchemy_cms-2.1.7 app/models/alchemy/essence_picture.rb
alchemy_cms-2.1.6 app/models/alchemy/essence_picture.rb
alchemy_cms-2.1.5 app/models/alchemy/essence_picture.rb
alchemy_cms-2.1.4 app/models/alchemy/essence_picture.rb
alchemy_cms-2.1.3 app/models/alchemy/essence_picture.rb
alchemy_cms-2.1.2 app/models/alchemy/essence_picture.rb