app/models/kuhsaft/brick.rb in kuhsaft-1.3.1 vs app/models/kuhsaft/brick.rb in kuhsaft-1.4.0
- old
+ new
@@ -2,23 +2,22 @@
class Brick < ActiveRecord::Base
include Kuhsaft::BrickList
belongs_to :brick_list, :polymorphic => true, :touch => true
- scope :localized, lambda { where(:locale => I18n.locale) }
- default_scope order('position ASC').localized
+ scope :localized, -> { where(:locale => I18n.locale) }
+ default_scope -> { order('position ASC').localized }
serialize :display_styles, Array
attr_accessible :locale,
:position,
:type,
:brick_list_id,
:brick_list_type,
:display_styles
- before_validation :set_locale
before_validation :set_position
validates :locale,
:position,
:type,
@@ -60,13 +59,9 @@
while parent
p << parent
parent = parent.respond_to?(:brick_list) ? parent.brick_list : nil
end
p.reverse
- end
-
- def set_locale
- self.locale = self.locale.presence || I18n.locale
end
def set_position
self.position = if self.position.present?
self.position