Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use of trix directly with trix_editor_tag by injecting into ActionView::Base #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zachfeldman
Copy link

This feels a bit icky to me and like I'm not doing it the true "rails way", but it does work on my project. Any suggestions welcome!

@maclover7
Copy link
Owner

Hi @zachfeldman! Two quick things about this PR--

  1. Would you be able to take a look into Action View's source code to see how Rails does this? Like you pointed out, the solution is a little hacky right now 😬

  2. Can you please add some additional test coverage of this new feature?

@zachfeldman
Copy link
Author

@maclover7 sure I'd be glad to help.

  1. I've looked into Action View's source code and have not found an example similar enough to this project to understand how to autoload and inject this code without injecting into activerecord::base. Some of the examples I've looked at:

https://github.com/oshchyhol/chargify_direct/blob/e13af53e99de06922795461d504b0db33c25447c/lib/chargify_direct.rb

My main thesis is that I have to include trix_editor_tag in FormTagHelper so I can call it directly in my code. I've been able to resolve it as defined by defining it directly in the module like so:

module ActionView
  module Helpers

    module FormTagHelper
      def trix_editor_tag(object_name, value, options)
      end
    end

  end
end

However, from here I get stuck in a loop of, "wait, this is already defined above" and trying to include it there instead of defining it (include TrixEditorHelper instead of the method definition above). Or I try to use the Tags::TrixEditor.new(object_name, method, self, options).render method similar to the FormHelper implementation, but it seems silly because that's calling trix_editor_tag underneath it all.

Frankly I'm pretty stumped here, would appreciate any guidance @maclover7 as to what you consider a proper way to inject this into activerecord.

I'm glad to do number 2 once I can take care of number 1! Appreciate any insights you might have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants