Sha256: 6434dd0d69649a9fdacb90747b949a3b4db0abaeb99d16dd71a955a54a2fc319
Contents?: true
Size: 1.01 KB
Versions: 8
Compression:
Stored size: 1.01 KB
Contents
module AslonSettings class Admin::Param < ActiveRecord::Base has_many :items, :class_name=>'Admin::ItemParam' accepts_nested_attributes_for :items attr_accessible :name, :pos ,:items_attributes ,:value def self.method_missing(method, *args) method_name = method.to_s super(method, *args) rescue NoMethodError if (param=self.find_by_name(method_name)) == nil && method_name !='to_ary' param=self.create!(:name=>method_name) else param end return param end def method_missing(method, *args) method_name = method.to_s super(method, *args) rescue NoMethodError if method_name =~ /=$/ puts method_name puts args.first var_name = method_name.gsub('=', '') value = args.first o= items.where(:name=>var_name).first if o==nil o=items.new o.name= var_name end o.value = value o.save #retrieve a value else (eval "items.where(:name=>'#{method_name}')").first.value end end end end
Version data entries
8 entries across 8 versions & 1 rubygems