app/models/app_config.rb in wheels-0.1.2 vs app/models/app_config.rb in wheels-0.1.3
- old
+ new
@@ -1,18 +1,26 @@
class AppConfig < ActiveRecord::Base
+ has_many :sitemaps, :as=>:resource
after_save :reload
- validates :name, :presence=>true
+
+ before_create :set_name
+
def self.[](name)
val = select{|t| t.name==name}[0].try(:value)
if val && (val==val.to_i.to_s)
val = val.to_i
end
val
end
+
def self.current
@current ||= AppConfig.all
end
- def self.reload
- @current = nil
+ def reload
+ AppConfig.instance_variable_set '@current', nil
+ end
+
+ def set_name
+ self.name = sitemaps[0].try(:menu_text) unless self.name
end
end