A gem is a good or bad depending on how well it solves the problem are designed for. And this is why the order below is stupid, there are not some better than others in this top, because their solve different problems between.
ADVICE: Avoid filling your applications with many gems.
Some of the ones listed below can be replaced by a bit of self-made code. In this way you create more durable applications over time.
Still, they are very necessary when we have little time and we are hardly validating a product. And that's the reason why I decided to include them.
Obvious, how not to include this gem. A classic. For those who do not have much time in Rails, Devise gives you everything you need for user authentication. Registration, sessions, password reset, etc.
It is really easy to use.
A management for uploading images with the ActiveRecord. Also very easy to use, with 1 simple line of code (literal) you can already have attachments in your resource.
Among other things, it provides us with the API client to upload the previous paperclip images to AWS S3, also in a super simple way.
It is responsible for commenting on our models with the fields of said table in db. Very useful if you handle large data structures.
Something like (
# == Schema Information # # Table name: posts # # id :bigint not null, primary key # title :string default(""), not null # body :text default(""), not null # created_at :datetime not null # updated_at :datetime not null # user_id :bigint not null # # Indexes # # index_posts_on_title (title) UNIQUE # index_posts_on_user_id (user_id) # # Foreign Keys # # fk_rails_... (user_id => users.id) #
It is used to generate random data, such as names, surnames, telephone numbers or emails. For those who spend more time testing, this gem may be a must. Fill your seeds with 0 effort.
# Random Book Title Faker::Book.title #=> "The Odd Sister"
Sidekiq helps us to process tasks in the background in an efficient way. Actually, I already talked about Sidekiq before. I leave the article in case you are interested.
Another classic. We will pass a resource to will_paginate and it generates the pagination according to what we indicate.
May be complementary to Devise. She validates and ensures that x email exists. A great little help to deal with spam or user errors.
Rails (and his community) respects his philosophy a lot, a great design pattern is decorators.
This adds an additional logic representation to the objects.
Imagine you have a User model, that user has
surname, now, instead of doing
user.name + "" + user.surname in the view, you can create a decorator for User, that inside has a full_name method, receive a User and return the full name.
A simple but representative example. Don't store logic in your views! Draper helps you implement it in a super simple way.
Through the slugs concept it lets you create pretty URLs and work with human-friendly strings as if they were numeric ids.
extend FriendlyId friendly_id :title, use: :slugged
Normally the URL to access this view would look something like http://localhost:3000/posts/1, but friendly_id takes the title (for example) and use it, instead of post id. Result, http://localhost:3000/posts/post-title-example
I have special affection for this gem. With it we can create graphics in a super fast way, in a single line of code.
<%= line_chart User.group_by_day(:created_at).count %>
It estimates us how long it can take the user to read certain text. Like, '3 minutes of reading'. It can be useful for a blog, to display it in top of the article body.
Count user views and impressions. How also which user saw such a thing and how many times.
No matter what they are building, if you handle money type data, this gem cannot be missing. Save multiple currencies and do the conversion.
Translation is a broad topic, but for some reason routes are rarely touched on and that also ends up impacting the user experience. This gem will do just that, translate the routes of your application as you indicate.
Another gem that can be complementary to Devise. CanCanCan allows us to authorize or not our users in certain actions. We establish roles under the concept of ability. Highly recommended.
Is it all, do you know any other gem that has solved your life and is not very popular? Tell us! 👋