rails_dictionary 0.0.9 → 0.0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -2,5 +2,6 @@
2
2
  add Rails Engine to redesign the gem
3
3
  use Rspec instead of Test::Unit to write test code
4
4
  remove many nonsence code
5
+ if update from lower version,should run "rails runner "DictType.new.delete_all_caches" on app root.
5
6
  0.0.1-0.0.8
6
7
  old mixin coding style
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 | 上海 | shanghai | 1 |
35
- | 2 | beijing | 北京 | Pékin | 1 |
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
@@ -1,3 +1,3 @@
1
1
  module RailsDictionary
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.9.1"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rails_dictionary
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.9
5
+ version: 0.0.9.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Raykin Lee