-
Notifications
You must be signed in to change notification settings - Fork 385
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
Move to Yarn? #555
Comments
Yes definitely. There are a few pull requests already, I just need to investigate that myself a little more. I always make these things harder then they need to be. I started refactoring the js a while ago, to write it more "contemporary", but then it is too big a job to just deploy quickly. Anyway it is my intention to work on cocoon this weekend:
For now you could already check out #454 ? |
Cool, thanks! |
Ah found this. I don't think you need to refactor the JS at all, I think you should be able to publish as an npm package with the JS just as it is (possibly very few changes), and it will work. The only potentially tricky thing is things like the jQuery dependency. But to avoid being a blocker, you can even not change that, not actually |
Rails 6.0 is out, and with a newly generated Rails 6.0 app, there is no way by default to use JS from a gem via the sprockets asset pipeline. (There should be some way to hack it back in, I haven't tried yet). For cocoon to keep being used in a Rails 6 world, it really needs it's JS released as an npm package. |
I make it works doing the following: Create a file in After that, add to your require("src/cocoon") I hope this helps you while we find a better solution. |
@alejandrodevs when you added the js to the src did you still include the gem in the gem file? |
@apocolyptic Yes, the gem has to be included in the Gemfile to have the whole functionality and the view helpers. |
Just add this |
Being new to Ruby and Rails I had been raking my brain as to why the add/remove links hadn't been working. Thank you @IsolatePy for your suggestion which made it work!! |
@irfanahm3d |
Until webpacker is supported, I think one of these two workarounds should be more obvious in the Cocoon documentation: I used the first one. Maybe I missed it, but I spent a decent amount of time wondering why Cocoon in my Rails 6 app wasn't completely working. |
Suggestion, until a oficial release solution: https://github.com/kollegorna/cocoon-vanilla-js |
@nathanvda 11 months have passed since this thread was opened. It would be really great to finally have an official release for Rails 6 |
Hi! This worked for me (rails 6.0.3.1, 'webpacker', '~> 5.1', '>= 5.1.1', but this maybe not important ):
|
oh wow I had no idea you could add packages in yarn from github! not as good as an actual release, but especially with cocoon being very very stable, that is a great workaround, thanks! The ability to add packages from github in yarn is actually HUGE, if this works it will make a lot of things so much easier, I'm going to look into it! |
@estafaa thanks for sharing this. It Worked! :) |
Not sure if this is really the best way to test, but it gets tests to pass for now. We're trying to test cocoon works with our attributes, and I guess cocoon is currently only doing sprockets though... so I guess it is best. Maybe we should include our own cocoon-like JS via some other method in the future... nathanvda/cocoon#555
Not sure if this is really the best way to test, but it gets tests to pass for now. We're trying to test cocoon works with our attributes, and I guess cocoon is currently only doing sprockets though... so I guess it is best. Maybe we should include our own cocoon-like JS via some other method in the future... nathanvda/cocoon#555
As Rails 6 is moving towards Webpacker, it would be really nice if the javascript for cocoon would be available through Yarn. Any plans for this? Thanks.
The text was updated successfully, but these errors were encountered: