Giter Club home page Giter Club logo

Comments (7)

jnicklas avatar jnicklas commented on June 2, 2024

Tricky. I have no idea how engines work. Could it be that they somehow end up using a different form builder? I'm afraid I'm not much help on this one.

from refile.

jensljungblad avatar jensljungblad commented on June 2, 2024

I looked at this a bit and it's not that the form builder helper isn't available; it is. It's the helper the form builder helper calls that isn't available, the @template.attachment_field here:

def attachment_field(method, options = {})
  self.multipart = true
  @template.attachment_field(@object_name, method, objectify_options(options))
end

None of the helpers defined in app/helpers/attachment_helper.rb seem to be available inside another engine.

from refile.

jensljungblad avatar jensljungblad commented on June 2, 2024

That being said, it's not difficult to include it yourself:

module Blorg
  class ApplicationController < ActionController::Base
    helper AttachmentHelper
  end
end

from refile.

jensljungblad avatar jensljungblad commented on June 2, 2024

There is, however, another issue with the helpers, from an engine perspective. The attachment_url helper calls refile_app_path. Because refile mounts itself at /attachments within Rails.application.routes, the path is only available through the main app.

That is, within another engine, you would have to refer to the refile path as main_app.refile_app_path.

from refile.

jensljungblad avatar jensljungblad commented on June 2, 2024

Which is also quite simple to fix yourself, by delegation:

module Blorg
  module ApplicationHelper
    def refile_app_path
      main_app.refile_app_path
    end
  end
end

However, these things should perhaps be made to work out of the box?

from refile.

jnicklas avatar jnicklas commented on June 2, 2024

I'm not sure. Does main_app work outside engines as well? If it does, then adding it is no harm, I guess. As for including the helper, I doubt there's really anything we can do there which isn't super hacky, so I'd rather not.

from refile.

jensljungblad avatar jensljungblad commented on June 2, 2024

Yes I believe main_app is always defined.

from refile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.