One of the plugins that make up the meta-rails project (
http://meta-rails.rubyforge.org
)
- is charged with making a diagram of the application class and provides a query generator
- these classes. To do this I needed to load drivers and their views directly from this plugin.
- after documenting and testing I have found a way to make it easy.
- drivers All ruby \u200b\u200bon rails plugins can have the file in your root folder init.rb
- plugin code in the Rails application.
- can use the following code:
Upload
running when loading rails application. This file is the hook (hook) which can be used to introduce
If we put our drivers in the plugin subdirectory app / controllers to load
directory = "# {RAILS_ROOT} / vendor / plugins / NOMBRE_DEL_PLUGIN" $ LOAD_PATH
if defined? (RAILS_GEM_VERSION) and RAILS_GEM_VERSION> = '1 .2.0'
Dependencies.load_paths
else raise "Engines plugin is Needed for running NOMBRE_DEL_PLUGIN with \\
Ruby on Rails version config.controller_paths
end
Analyzing the code we see that this code is executed differently depending
use Ruby on Rails version 1.2.0 or later to previous. This is because to work
in versions prior to 1.2.0 we need the engines plugin installed ( http://rails-engines.org ). Once put this code we can create our drivers doing that inherit from ActionController:: Base class
MetaQuerierController Views
for our drivers
- Once we loaded the drivers, we must assign
- subdirectories where they can find their views. We do this by changing a class variable with self.template_root:
MetaQuerierController
self.template_root
class = "# {RAILS_ROOT} / vendor / plugins / meta_querier / app / views /" end
I hope you find it useful, you can find more information at:
<< controller_path
http://weblog.techno-weenie.net/2007/1/24/understanding-the-rails-initialization-process
<< controller_path
< 1.2.0" if Dir["#{RAILS_ROOT}/vendor/plugins/engines"].empty?
0 comments:
Post a Comment