Rails engines question

I would like to use my own directory named forms inside my own engine. I
know I can add it to loading paths like this in application.rb
module MyAPP
class Application < Rails::Application
config.paths[“forms”] = Rails.root.join(‘vendor/myapp/forms’)
end
end
or inside

and can access it inside controller like this:

MyAPP::Application.config[“forms”]

Which is a bit of a problem since my engine would have to know
application name inside which it runs. So, my questions are:

  1. Is there a better way to access config object?. Like session or
    params inside controller.

  2. What Rails API method is used to search files for example in
    MyAPP::Application.config[“views”] paths and returns name of file (view)
    if find.

by
TheR

I found it myself.

  1. Rails.configuration.paths[“forms”]

  2. I did my own method for now.

def find_form_file(form)
Rails.configuration.paths[“forms”].each do |path|
f = “#{path}/#{form}.yml”
return f if File.exist?(f)
end
p “Form file #{form} not found!”
nil
end

by
TheR

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs