23個實用的 Gems 來搭建一個Rails應用

jopen 9年前發布 | 7K 次閱讀 Gems

1. Better Errors & Binding of Caller

These two gems are working to replace the Rails default error page to show you where the mistake was made, propose you a REPL (console), inspect params, your instance variables and to easily browse stack of an error.

2. Pry Byebug

Pry offers a colorful alternative to IRB and Pry Byebug helps to stop code execution with breakpoints, to offer you the opportunity to test/debug your application on the run.

3. Puma

Puma is a faster HTTP server Webrick (proposed base on your Rails applications). This gem can increase the daily performance of your site and better manage any traffic load by addressing several requests in parallel.

4. Quiet Assets

Quiet Assets allows you to relieve the log from your developer console by removing queries HTTP related to the pipeline assets Rails. Say goodbye to multiple “GET /assets/blog/thumbnail-api-webhook-tutorial-be5d3373ac225d0d5d0f0060aa7b3eeb.jpg HTTP/1.1″ 304 – 0.0154 and relieve your eyes.

5. Faker

This is indispensable to populate your basis of false information (name, email, address …) when developing your application without the need to create everything by hand!

6. Letter Opener

Letter Opener allows you to preview your emails directly in your browser without having to include a system for sending emails within your development environment.

Deployment

You can add the following gems in your Gemfile the group :Production to only benefit when your application is Pushee on Heroku or any other service.

group :development do
  gem "better_errors" 
  gem "binding_of_caller" 
  gem "quiet_assets" 
  gem "pry-byebug" 
  gem "faker" 
  gem "letter_opener" 
end

7. 12factor Rails

12factor rewrites some parameters of Rails to facilitate scalability and development regular update of your application according to the conventions of 12factor. This gem is primarily concerned with providing access to logs and also the folder app/assets to be used in production in order to give access to your CSS, js and image files.

Some useful features

8. Bootstrap Sass

This is very practical after you install this gem and imported the Bootstrap styles in app/assets/stylesheets/application.scss via @import "bootstrap-sprockets"; and @import "bootstrap"; then you’ll have access to all Bootstrap CSS framework via your HTML markup.

9. Simple Form

Simple Form simplifies the creation of your forms with a very light syntax and gives you the ability to summon and customize the label elements, hints, errors and input according to your will.

Note that this gem is easily integrated with Bootstrap Foundation and through its installation options.

10. Currency & Omniauth

Currency offers a complete authentication solution (Model, View, and Controller) reliable and secure. In addition to providing multiple users the ability to be connected at the same time, this gem can also be embellished module Omniauth to enable your users to connect to your service via 非死book Connect or 推ter.

11. Pundit

Pundit provides a simple and centrally manage user permissions to your applications in app/policies. You can duplicate this file all your controller classes accompanied by Policy suffix. Then set the rights of your current_user each class method.

12-14. Paperclip, Carrierwave & Dragonfly

These three gems with slightly different functions are proposing to manage the upload and processing of your images. On one side, Paperclip and Carrierwave will take care of resizing then store the original file and all necessary in resizing your template of the same image.

On the other side, Dragonfly. This gem stores the original version at first and resizes on the fly for each user action. This requires the installation of a cache refill images to minimize server load.

15. Gibbon

Gibbon is a wrapper dedicated to the MailChimp API to help you synchronize your database to refine the management of your lists, create new segments based on the actions of your users, or just create a registration form within your application.The advantage of this gem on the javascript widget is the ability to disable the double opt-in.

16. Google Maps for Rails

Gmaps4rails allows you to quickly customize your Google Maps to include markers and dynamic information windows.

17. Kaminari

Kaminari provides complete and fully customizable pagination. Once installed, all your models can be paginated without any action required on your part towards models and helpers.

18. High Voltage

High Voltage allows you to easily manage your static pages. After installation, you can simply create a folder pages in your views and place your pages. No configuration rooting, no helpers to create, or controller. Everything is taken care of for you!

19. Figaro

Figaro lets you enhance the security of your application by hiding tokens, passwords and other credentials of APIs to prevent Git store (and thereby to everyone have access). You can still have access via the environment variable ENV .

20. Rails-i18n

You can translate and locate your site quickly thanks to rails-i18n. Write all your translations in files yml placed in config>locals and call them in your views according to the language selected by your users.

21. Cocoon

Cocoon allows easier management of nested forms allowing to create, destroy, update all models involved in a single view.

22. Active Admin

All directors of your service are not necessarily developers, and, therefore, can not be content with a heroku run bundle exec rails c. Active Admin to create a full management interface and easily customizable with all the functionality of your application.

23. Sidekiq

Sidekiq is one of the gems worker management, to perform the heavy processing of your application in asynchronous processes, put in a queue. Since Rails 4.2, a unified framework, ActiveJob is available. Sidekiq is consistent with this approach. An example of using Sidekiq is sending an email to 10 users. If you perform this action in a controller, the user will wait long as treatment is done and have a feeling of slow navigation. If you unload this treatment in a sidekiq worker, you may return a web page to your user quickly by entrusting to the long Sidekiq task.

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!