DEV Community

Discussion on: Your first ruby gem 💎

Collapse
 
romanvanloo profile image
RomanVanLoo

Great article, but how do you differentiate your gem from the already pretty famous "Cocoon"?

Collapse
 
lso profile image
Louis Sommer • Edited

Hey Roman ! Thanks ! Our take on the issue is quite different from cocoon. We're providing users with a complete wrapper around nested_attributes, which includes :

  • Easy configuration and syntax in the model
  • Easier permission of attributes in the controller
  • Either a preconfigured one-liner, or a very flexible way of displaying fields on the view side (without having to resort to quirky and unreliable data attributes)
  • Generators, including one that generates all the above config + a pre-filled partial. Also, cocoon is implemented in jquery, whereas we chose to implement everything with stimulus. Have a look at the doc for more details 😬
Collapse
 
romanvanloo profile image
RomanVanLoo

Alright cool! I definitely try it out next time in need for nested forms! ✌️
Cool to use stimulus, it's definitely an underrated framework!

Collapse
 
siarhei_siniak_marketing profile image
Siarhei Siniak
  1. links 1.1. github.com/nathanvda/cocoon/issues (3k on github) github.com/nathanvda/cocoon/issues... github.com/dabroz/cocoon-js-vanilla 1.3. stimulus.hotwire.dev/reference/con... turbo.hotwire.dev/reference/drive github.com/hotwired/stimulus (10.5k on github)
  2. it's cool that you've written a simple version of cocoon and are capable of customizing few aspects of it, like say replacing jquery with stimulus, etc. Has it come due to a difficulty of sending PRs into an existing code base?
Collapse
 
lso profile image
Louis Sommer

In all honesty, we didn't feel like doing so. Neither of us ever liked working with cocoon but still did because it was the only available tool to help with the issue at hand. I think contributing to an existing codebase makes sense for projects you love and wish to support and enhance, but here we really wanted to start from scratch with a completely different approach.
That being said, it's one of our main references for this project, and it helped us tremendously in writing some parts of the gem. Like I said, learn from the best ; (the missing part was "Then, try and make it better !" 🤓)