rails_dictionary 0.0.9 → 0.0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -10,6 +10,10 @@ Rail3
|
|
10
10
|
or
|
11
11
|
gem "rails_dictionary",:git => 'git://github.com/raykin/rails_dictionary'
|
12
12
|
|
13
|
+
!!For user who update from old version to 0.0.9 or higher,Please run following command on app root
|
14
|
+
rails runner "DictType.new.delete_all_caches"
|
15
|
+
See change log for brief info.
|
16
|
+
|
13
17
|
== Sample
|
14
18
|
Run following task will give you a simple start.Maybe you should try it in a new application first.
|
15
19
|
rake dicts:generate
|
@@ -31,8 +35,8 @@ These task are just generate table dictionaries,dict_types,students and some sam
|
|
31
35
|
+----+----------+---------+----------+--------------+
|
32
36
|
| id | name_en | name_zh | name_fr | dict_type_id |
|
33
37
|
+----+----------+---------+----------+--------------+
|
34
|
-
| 1 | shanghai | 上海
|
35
|
-
| 2 | beijing | 北京
|
38
|
+
| 1 | shanghai | 上海 | shanghai | 1 |
|
39
|
+
| 2 | beijing | 北京 | Pékin | 1 |
|
36
40
|
+----+----------+---------+----------+--------------+
|
37
41
|
2 rows in set
|
38
42
|
irb(main):016:0> Student.select("id,email,city,school").all
|
@@ -108,6 +112,4 @@ There are no convention and implemention to map Class like Ckeditor::Asset to a
|
|
108
112
|
|
109
113
|
Rebuild core code.Using Rails engine.
|
110
114
|
|
111
|
-
Make cached type of DictType to an array of symbols
|
112
|
-
|
113
115
|
Rewrite Testing,make it more maintainable.
|
@@ -29,7 +29,7 @@ module RailsDictionary
|
|
29
29
|
|
30
30
|
# add a belongs_to(Dictionary) association and a named_{column} method
|
31
31
|
def add_dynamic_column_method
|
32
|
-
dict_mapping_columns.each { |e| belongs_to "#{e.to_s}_dict".to_sym,class_name: "Dictionary",foreign_key: e }
|
32
|
+
dict_mapping_columns.each { |e| belongs_to "#{e.to_s}_dict".to_sym,class_name: "Dictionary",foreign_key: e.to_sym }
|
33
33
|
dict_mapping_columns.each { |ele| named_dict_value ele.to_sym }
|
34
34
|
end
|
35
35
|
|
@@ -33,11 +33,14 @@ module RailsDictionary
|
|
33
33
|
# I don't know which is better,but descendants contains subclass of subclass,it contains more.
|
34
34
|
# Class like +Ckeditor::Asset+ transfer to "ckeditor/asset",but we can not naming method like that,
|
35
35
|
# So it still not support, the solution may be simple,just make another convention to escape "/"
|
36
|
+
# TODO:
|
37
|
+
# To cache this method output need more skills on how to caculate ActiveRecord::Base.descendants
|
38
|
+
# Temply remove the cache
|
36
39
|
def tab_and_column
|
37
|
-
Rails.cache.fetch("DictType.tab_and_column") do
|
40
|
+
#Rails.cache.fetch("DictType.tab_and_column") do
|
38
41
|
all_model_class=ActiveRecord::Base.descendants.map(&:name).map(&:underscore)
|
39
42
|
all_types.map(&:to_s).extract_to_hash(all_model_class)
|
40
|
-
end
|
43
|
+
#end
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
@@ -45,7 +48,7 @@ module RailsDictionary
|
|
45
48
|
def delete_all_caches
|
46
49
|
Rails.cache.delete("DictType.all_types")
|
47
50
|
Rails.cache.delete("DictType.cached_all")
|
48
|
-
Rails.cache.delete("DictType.tab_and_column")
|
51
|
+
#Rails.cache.delete("DictType.tab_and_column")
|
49
52
|
return true
|
50
53
|
end
|
51
54
|
end
|