Please visit:
1: the introduction of new features to the controller
My approach:
I tried to introduce in the application controller extra modules:
require "string"
This "string" the source file is located in models / string.rb defined as follows:
class String
def to_big5
covu2g = Iconv.new('gbk', 'utf-8')
covb2u = Iconv.new('utf-8', 'big5')
str = covu2g.iconv(self)
str = iconv_chinese_by("to_big5.tab", str)
str = covb2u.iconv(str)
return str
end
def to_gb2312
iconv_chinese_by("to_gb2312.tab")
end
...
end beast approach:
include ExceptionLoggable, BrowserFilters, AuthenticationSystem
Module is located in the former two plugin, the last one in the lib Medium
Second: to model the introduction of new features
My approach:
in models / user.rb
require "path_to_Activity::UserActivity" require "path_to_Activity::UserActivity" include Activity::UserActivity include Activity::UserNewyearcard
And Activity:: * the source file on my models under
The results of the first visit after the normal page always said
uninitialized constant Activity::UserActivity And I again require Activity:: * the code moved to the following application.rb Medium
require File.join(File.dirname(__FILE__), "..", "models", "Activity/user_activity.rb") require File.join(File.dirname(__FILE__), "..", "models", "Activity/user_newyearcard.rb")
The results still error
Three: How to extend the controller / module as well as other
Extended Object: controller or model or the overall
Expansion of type: add method (class, instance user-defined categories), or hack (such as string, such as the framework for the core category, or add methods)
Expansion of the location: module source code location (models under, plugin Medium (Obviously not all can plugin under), lib under)
For instance: beast expansion controller Ways to add the source code is located in its lib use plugin or way include Module
Which heroes can be summarized under the basic usage and why so many use it?
Four: Is the expansion should be include / extend Module way (and the definition included in Module callback)
And should not require + open class used to redefine







