blob: 7769b7fa4fca0d46391712ea18df3d09a10cb6ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
class MenuItem < ApplicationRecord
default_scope -> { where(:type => "MenuItem") }
translates :title
acts_as_list :scope => :type
before_save :determine_type_id
private
def determine_type_id
case self.class.name
when "MenuItem"
self.type_id = 1
when "FeaturedArticle"
self.type_id = 2
end
end
end
class FeaturedArticle < MenuItem
default_scope -> { where(:type => "FeaturedArticle") }
end
|