我的应用程序是表单构建器:定义表单,然后以通常的CRUD方式呈现激活的表单.激活表单的过程触发了FormManager创建主Form对象的子类(我使用STI ActiveRecord来创建type,使用的子类Object.const_set()).可以停用活动表单,这涉及杀死该子类定义(使用Object.const_send(:remove...))
我的应用程序只需要一个 FormManager对象.最好的方法是什么?我目前正在使用一个类变量ApplicationController来实现这个...它的工作原理,但似乎有点笨重:
require 'lib/form_manager.rb'
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
attr_reader :registry
protect_from_forgery
@@registry = FormManager.new
end
Run Code Online (Sandbox Code Playgroud)
我正在运行ruby 1.8.7,在开发模式下运行2.3.11 - 我看到这只是因为我处于开发模式?