우리는 Sinatra를 사용하여 Google 서비스에 대한 HTTP API 액세스를 제공하지만 대부분 사용자 지향 기능은 Rails 2.3.8을 사용합니다. Sinatra와 Rails 응용 프로그램은 모두 RAILS_ROOT/app/models 디렉토리에 정의 된 동일한 ActiveRecord 모델을 공유합니다. 시나 응용 프로그램에 대한 설치 스크립트에서 Sinatra 앱의 Rails 앱에서 ActiveRecord 모델을 사용하면 여러 경고가 발생합니다.
은, 모든 모델은ActiveSupport::Dependencies
를 사용하여로드하고 데이터베이스 연결 초기화 :
require 'active_support'
relative_load_paths = %w(app/models)
::ActiveSupport::Dependencies.load_paths = relative_load_paths.map { |path|
File.expand_path(path, RAILS_ROOT)
}
require 'active_record'
config_path = File.expand_path('config/database.yml', RAILS_ROOT)
all_envs_config = YAML.load(File.read(config_path))
config = all_envs_config[env.to_s]
::ActiveRecord::Base.establish_connection(config)
혼자 위의 경고를 생성하지 않습니다,하지만 때마다 우리의 모델의
/path/to/ruby/gems/activesupport-2.3.8/lib/active_support/vendor.rb:32: warning: redefine normalize_translation_keys
/path/to/ruby/gems/activerecord-2.3.8/lib/active_record/validations.rb:393: warning: `*' interpreted as argument prefix
/path/to/ruby/gems/activerecord-2.3.8/lib/active_record/validations.rb:29: warning: method redefined; discarding old message
/path/to/ruby/gems/activerecord-2.3.8/lib/active_record/dirty.rb:40: warning: `*' interpreted as argument prefix
/path/to/ruby/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:228: warning: `*' interpreted as argument prefix
/path/to/ruby/gems/sinatra-1.2.0/lib/sinatra/base.rb:1096: warning: method redefined; discarding old options
/path/to/ruby/gems/shoulda-2.10.3/lib/shoulda/context.rb:4: warning: method redefined; discarding old contexts
/path/to/ruby/gems/shoulda-2.10.3/lib/shoulda/context.rb:330: warning: method redefined; discarding old subject_block
/path/to/ruby/gems/shoulda-2.10.3/lib/shoulda/proc_extensions.rb:4: warning: method redefined; discarding old bind
/path/to/ruby/gems/actionpack-2.3.8/lib/action_controller/integration.rb:99: warning: `*' interpreted as argument prefix
/path/to/ruby/gems/actionpack-2.3.8/lib/action_controller/test_process.rb:90: warning: method redefined; discarding old path
/path/to/ruby/gems/actionpack-2.3.8/lib/action_controller/test_process.rb:397: warning: method redefined; discarding old get
/path/to/ruby/gems/actionpack-2.3.8/lib/action_controller/test_process.rb:402: warning: method redefined; discarding old post
/path/to/ruby/gems/actionpack-2.3.8/lib/action_controller/test_process.rb:407: warning: method redefined; discarding old put
/path/to/ruby/gems/actionpack-2.3.8/lib/action_controller/test_process.rb:412: warning: method redefined; discarding old delete
/path/to/ruby/gems/actionpack-2.3.8/lib/action_controller/test_process.rb:417: warning: method redefined; discarding old head
/path/to/ruby/gems/activerecord-2.3.8/lib/active_record/reflection.rb:261: warning: instance variable @collection not initialized
/path/to/ruby/gems/activerecord-2.3.8/lib/active_record/reflection.rb:261: warning: instance variable @collection not initialized
/path/to/ruby/gems/activerecord-2.3.8/lib/active_record/reflection.rb:261: warning: instance variable @collection not initialized
...
이 필요할 때마다 때문에 자동으로 모델을로드 할 수 ActiveSupport :: 종속 우리 소용이, 아니면이 다음 API 측에서 사용된다 (예를 들어 시험에서), 여러 경고가 콘솔에 출력됩니다위의 설정 스크립트에서이 동작을 일으킬만한 다른 사항이 있습니까?