2012-03-27 48 views
3

基本上我想加载此:是否可以避免使用Rails 3加载action_controller?

require "active_record/railtie" 
require "active_resource/railtie" 
require "action_mailer/railtie" 

,并不会加载action_controller因为在这个特定情况下,我都用不到它。在the code in Rails' master

看,我可以看到:

# For now, action_controller must always be present with 
# rails, so let's make sure that it gets required before 
# here. This is needed for correctly setting up the middleware. 
# In the future, this might become an optional require. 
require "action_controller/railtie" 

...所以我想知道:是否有可能加载Rails的只有active_recordactive_resourceaction_mailer,还是我总是要加载action_controller

+2

为什么在这种情况下你需要使用导轨?只需在自己的脚本中包含ActiveRecord,ActiveResource和ActionMailer gems? – cpjolicoeur 2012-03-27 14:11:58

+0

出于好奇,你为什么要放弃ActionController?是否有一些更深层次的优化(例如尽可能最小的内存占用)或其他类似的东西? – jefflunt 2012-03-27 14:14:45

+0

@cpjolicoeur:我试过了,最后有一个模拟导轨的〜100行文件。 – marcgg 2012-03-27 14:21:52

回答

0

Rails是Web的MVC框架,而Resque是一个Redis支持的用于创建后台作业的Ruby库。

如果你需要模型,然后使用ActiveRecord。

如果您需要视图,Ruby在其标准库中有ERB。

如果你不需要路由和控制器,那么使用web框架没有任何意义。

相关问题