nicolasblanco/rails_param

rails_param loads the whole rails suite

Closed this issue · 2 comments

Basic Info

rails_param loads the whole rails suite even when it is not needed.

  • rails_param Version: 1.2.0
  • Ruby Version: 3.0
  • Rails Version: 6.1

Issue description

In my project I don't need the whole rails suite. My Gemfile contains only the next rails gems.

gem 'actionpack', '~> 6.1'
gem 'activejob', '~> 6.1'
gem 'activemodel', '~> 6.1'
gem 'activerecord', '~> 6.1'
gem 'activesupport', '~> 6.1'

Unfortunately rails_param loads the whole rails suite including actioncable, actionmailer, etc..
I think it can be simply fixed by modifying gem specification to

s.add_development_dependency 'rspec', '~> 3.4'
s.add_development_dependency 'rspec-rails', '~> 3.4'

s.add_dependency 'actionpack', '>= 3.2.0'
s.add_dependency 'activesupport', '>= 3.2.0'

What is the point of having the whole rails dependency?

s.add_dependency 'rails', '>= 3.2.0'

Ah yes, rails_param have been implemented under the assumption that it will run inside Rails projects, but I guess more people are taking the road of creating their own mini-framework based on Rails pieces to remove unnecessary overhead.

This should definitely be possible, it will just require some trial-and-error to identify the exact configuration, but it shouldn't affect the majority of users who will be loading this gem after Rails anyway.

I'm a bit short on time at the moment, but I'd be happy to review a PR attempting this.
Obviously on top of the gemspec, changes will be needed on specs and other files to ensure we're not running tests loading the whole rails suite. Otherwise we won't know if this works or not in the real world

This was closed in #88 🎉
Thank you @alexeyschepin