Hello, Using an external YAML file for storing static datas is cool. And doing so in a basic Rails application is easy using in config/initializers/load_config.rb such: CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml") ...after what datas can be called in application.rb with CONFIG[''something'']. But how can we load the YAML configuration file of a plugin (in its controller for instance)? For example if my plugin is in vendor/plugins/my_plugin and its YAML file is in vendor/plugins/my_plugin/config.yml? And I have an other question about this topic: is that possible to complet the Rails internationalization''s YAML files stored in config/locales/ using a additionnal YAML file into the plugin (in order to generate dynamic flash messages for instance in plugin''s controllers, like so: flash[:error] = t(there_is_an_error))? Many thanks for any answers. D. -- Posted via http://www.ruby-forum.com/.
On Aug 14, 3:07 pm, "David B." <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello, > > Using an external YAML file for storing static datas is cool. And doing > so in a basic Rails application is easy using in > config/initializers/load_config.rb such: > CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml") > ...after what datas can be called in application.rb with > CONFIG[''something'']. > > But how can we load the YAML configuration file of a plugin (in its > controller for instance)? For example if my plugin is in > vendor/plugins/my_plugin and its YAML file is in > vendor/plugins/my_plugin/config.yml? >Well you can have your plugin''s code do anything you want, including read in such a yaml file if you want.> And I have an other question about this topic: is that possible to> complet the Rails internationalization''s YAML files stored in > config/locales/ using a additionnal YAML file into the plugin (in order > to generate dynamic flash messages for instance in plugin''s controllers, > like so: flash[:error] = t(there_is_an_error))?You could try adding the appropriate folder(s) to the i18n load path. Fred> > Many thanks for any answers. > > D. > -- > Posted viahttp://www.ruby-forum.com/.
Thank you for your answer, Frederick. Is there an example of plugin using those mechanisms? -- Posted via http://www.ruby-forum.com/.
On Aug 15, 9:09 am, "David B." <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Thank you for your answer, Frederick. > > Is there an example of plugin using those mechanisms?Not that I''ve seen, but then I haven''t looked. The rails I18n guide probably discusses the i18n load path stuff and the configuration stuff should be straight forward - loading some yaml and assigning it to a constant isn''t going to be radically different just because a plugin is involved. Fred> -- > Posted viahttp://www.ruby-forum.com/.