Forum: Ruby on Rails Rails engines question

Be07c8d0d6867fd9a0d525f7d17600e2?d=identicon&s=25 Damjan Rems (ther)
on 2013-03-08 23:27
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')
or inside

and can access it inside controller like this:


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.

Be07c8d0d6867fd9a0d525f7d17600e2?d=identicon&s=25 Damjan Rems (ther)
on 2013-03-09 11:12
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)
  p "Form file #{form} not found!"

Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.