rails - is it ok to install multiple gems doing the same thing?
I am curious as to if it's okay to install multiple gems that perform the same function into one app. What are the protocols for doing or not doing this?
Example:
- using multiple gems in one m开发者_开发技巧odel - Using auth logic to authenticate user and using devise for email confirmation
- using multiple gems in different models - Using sunspot for search in your blog model and using metasearch in your products model
Thanks
Unless there are constants overlapping, you should be okay, technically-speaking.
For instance, dynamic methods like Model.search
being provided by two different gems could cause issues. This may not occur if the gem allows you to specify which models to hook into.
And, as others have pointed out, gems may also have conflicting dependencies.
Whether or not this is acceptable, and/or redundant, well..
In my personal opinion, it is ok, as long as the gems are different enough so that the benefit is worth it. If they only perform the same function, it would be beneficial to use only one of them.
My example here is will_paginate
and kaminari
. I used will_paginate
a long time (even in Rails 3 the beta version), then found kaminari
through a webinar of Ryan Bates and switched in one application completely to kaminari
. This has a price tag, and is only worth if you will stay with that decision. To use both, you as a developer has to know both of them, with the differences, and the different options. I don't think that it is worth.
It is fine. But, sometimes gems have conflicting dependencies. You might want to make sure you don't run into that issue. Look at Gemfile.lock for dependencies. Personally, it is better to keep it clean unless there is a strong reason to.
精彩评论