├── 1_ruby_web_frameworks ├── hanami │ └── details │ │ └── architectures.md └── rails │ ├── action_cable.md │ ├── active_record_query.md │ ├── details │ ├── architectures.md │ └── development_and_maintain_projects.md │ └── major_updates_of_rails_version.md ├── 5_documents └── arel_doc.md ├── 6_books ├── Rails - Component Based Rails-Applications.pdf ├── Rails - Lean Publishing Growing Rails Applications in Practice (2014).pdf ├── Rails - Learn Rails 5-2.pdf ├── Rails - Modular Rails The Complete Guide to Modular Rails Applications.pdf ├── Rails - Rails 5 Test Prescriptions.pdf ├── Rails - Service-Oriented Design with Ruby and Rails.pdf ├── Ruby - Design Patterns in Ruby (2007).pdf ├── Ruby - Metaprogramming Ruby 2nd.pdf ├── Ruby - Practical Object-Oriented Design - 2nd.pdf ├── Ruby - Refactoring Ruby.pdf ├── Ruby - Ruby Best Practices.pdf ├── Ruby - Ruby Performance Optimization.pdf ├── Ruby - Ruby Under a Microscope.pdf ├── Ruby - Test Driven Development in Ruby.pdf └── Ruby - Well grounded Rubyist - 3rd.pdf ├── 7_gems └── useful_gems.md └── README.md /1_ruby_web_frameworks/hanami/details/architectures.md: -------------------------------------------------------------------------------- 1 | # Architectures of Hanami 2 | 3 | -------------------------------------------------------------------------------- /1_ruby_web_frameworks/rails/action_cable.md: -------------------------------------------------------------------------------- 1 | # Rails - Action Cable 2 | 3 | -------------------------------------------------------------------------------- /1_ruby_web_frameworks/rails/active_record_query.md: -------------------------------------------------------------------------------- 1 | # Rails - Active Record Query 2 | 3 | ## I. Query 4 | 5 | ### 1. Using native Active Record Query 6 | 7 | ### 2. Using Arel for complex queries 8 | 9 | ### 3. Using raw query 10 | 11 | ## II. Work with large datasets -------------------------------------------------------------------------------- /1_ruby_web_frameworks/rails/details/architectures.md: -------------------------------------------------------------------------------- 1 | # Architectures of Rails 2 | 3 | ## I. Model-View-Controller (MVC) 4 | 5 | - Default architecture of Rails 6 | - You can read more in [https://guides.rubyonrails.org](https://guides.rubyonrails.org) 7 | - This architecture belongs to Monolothic architecture. Normaly, we should modulize our code base on business units to improve the scalability in future. 8 | 9 | ## II. Abstract Layers in Rails 10 | 11 | - You can read the book `Layered Design for Ruby on Rails - Viladimir Dementyev` to know more: 12 | - Abtract Layers in Rails 13 | - Something default of Rails is not good enough 14 | - When Rails Abstracts are not enough 15 | - Custom to add more layers into Rails 16 | 17 | ## II. Components based (Modularizing Rails) 18 | 19 | - You can read the book `Components-Based Rails Applications - Stephan Hagemann` to know more: 20 | - Utilizing [Rails Engine](https://guides.rubyonrails.org/engines.html) to build Rails application with Component-Based 21 | - What is the benefits ? 22 | - Improved Communication of Intent 23 | - Improved Collaboration Among Developers 24 | - Improved Creation of Features 25 | - Improved Maintenance of the Application 26 | - Improved Comprehension of Application Parts 27 | -------------------------------------------------------------------------------- /1_ruby_web_frameworks/rails/details/development_and_maintain_projects.md: -------------------------------------------------------------------------------- 1 | # Development and Maintain projects 2 | 3 | ## I. Set up for development 4 | 5 | ### 1. What should be take care 6 | 7 | #### a. Documenting from begin 8 | 9 | #### b. Upgrate code quality with tests and reports 10 | 11 | ##### Support tools 12 | 13 | - Linting and checking - `rubocop` 14 | 15 | ##### Reports 16 | 17 | - Test coverage - `simplecov` 18 | - Code quality - `rubycritic` 19 | 20 | #### c. Performance of app 21 | 22 | ## II. Deployment strategies 23 | 24 | - Deploy by scripting 25 | - Deploy by containers 26 | - Mix solutions 27 | 28 | ### 1. How many we can deploy ? 29 | 30 | ### 2. You should monitor your errors 31 | 32 | ### III. Maintain your app 33 | 34 | #### 1. Benchmark 35 | 36 | #### 2. Optim 37 | - Check and optimize Rails 38 | -------------------------------------------------------------------------------- /1_ruby_web_frameworks/rails/major_updates_of_rails_version.md: -------------------------------------------------------------------------------- 1 | # Major updates of Rails versions 2 | 3 | You can check futher in section "Release Notes" of [Rails Guides](https://guides.rubyonrails.org/) 4 | 5 | ## Rails 5 6 | 7 | - Rails 5 requires Ruby 2.2.2 or newer. 8 | 9 | ### 5.0 (June 2016) 10 | 11 | - Add module `Action Cable` - It integrates Websockets in Rails app, make implementing real-time features more easy. 12 | - Support Api Only when generate Rails 13 | 14 | ```bash 15 | rails new my_api --api 16 | ``` 17 | 18 | - Improve Active Record attributes API 19 | - Use method `attribute` to override types and default values of attributes in ActiveRecord (normally, type and default values set via schema.rb) 20 | - an `attribute` doesn't need to stick with a column in database 21 | 22 | ### 5.1 (May 2017) 23 | 24 | - Support `Yarn` to manange Javascript dependencies 25 | - Support `Webpack` as a Javascript asset bundler 26 | - Encrypted secrets, Secrets will be decrypted in production, using a key stored either in the `RAILS_MASTER_KEY` or file `.key` 27 | 28 | ```bash 29 | bin/rails secrets:setup 30 | ``` 31 | 32 | ### 5.2 (April 2018) 33 | 34 | ## Rails 6 35 | 36 | - Rails 6 requires Ruby 2.5.0 or newer 37 | 38 | ### 6.0 (August 2019) 39 | 40 | - Add a new task for update Rails version. After updating the Rails version in the `Gemfile` run command 41 | 42 | ```bash 43 | rails app:update 44 | ``` 45 | 46 | - Load code in mode `zeitwerk` (the old one is `classic`), require file structure more strictly 47 | - Add module `ActionMailbox` - allows you to route incoming emails to controller-like mailboxes 48 | - Add module `Action Text` - brings rich text content and editing to Rails (Normally used in Rails View) 49 | - Support Parallel Testing 50 | - Support Action Cable Testing 51 | 52 | ### 6.1 (December 2020) 53 | 54 | - Support ability to switch connections per-database with method `connect_to` [Read more](https://github.com/rails/rails/pull/40370) 55 | 56 | ```ruby 57 | # Example 58 | ApplicationRecord.connected_to(shard: :shard1, role: :primary) do 59 | User.first # reads from ApplicationRecord shard1 primary 60 | Shard.first # reads from GlobalRecord default primary 61 | end 62 | ``` 63 | 64 | - Support horizontal sharding (same schema, multiple partitions) 65 | 66 | ```yml 67 | # database.yml config 68 | production: 69 | primary: 70 | database: my_database 71 | primary_shard_one: 72 | database: my_database_shard_one 73 | ``` 74 | 75 | ```ruby 76 | # Model config 77 | class ApplicationRecord < ActiveRecord::Base 78 | self.abstract_class = true 79 | 80 | connects_to shards: { 81 | default: { writing: :primary }, 82 | shard_one: { writing: :primary_shard_one } 83 | } 84 | end 85 | 86 | # How to use 87 | ActiveRecord::Base.connected_to(shard: :shard_one) do 88 | # Read from shard one 89 | end 90 | ``` 91 | 92 | - "Strict" Loading Associations. Add `#strict` to any record to prevent lazy loading of associations (use `preload`) 93 | - "Delegated Types" is an alternative to single-table inheritance. [Read more](https://github.com/rails/rails/pull/39341) 94 | - Destroy Associations Async - The ability for applications to destroy associations in a background job, `destroy_async`. 95 | 96 | ```ruby 97 | class Person < Application 98 | has_many :classes, dependent: :destroy_async 99 | end 100 | ``` 101 | 102 | ## Rails 7 103 | 104 | - Rails 7 requires Ruby 2.7. 0 or newer 105 | 106 | ### 7.0 (December 2021) 107 | 108 | ### 7.1 (October 2023) 109 | 110 | - Generate Dockerfiles for new Rails applicatons 111 | - Add `ActiveRecord::Base.normalizes` - declares an attribute normalization 112 | 113 | ```ruby 114 | class User < ActiveRecord::Base 115 | normalizes :email, with: -> email { email.strip.downcase } 116 | normalizes :phone, with: -> phone { phone.delete("^0-9").delete_prefix("1") } 117 | end 118 | 119 | user = User.create(email: " CRUISE-CONTROL@EXAMPLE.COM\n") 120 | user.email # => "cruise-control@example.com" 121 | 122 | User.normalize_value_for(:phone, "+1 (555) 867-5309") # => "5558675309" 123 | ``` 124 | 125 | - Add `ActiveRecord::Base.generates_token_for` - defines the generation of tokens for a specific purpose. Generated tokens can expire and can also embed record data 126 | 127 | ```ruby 128 | class User < ActiveRecord::Base 129 | has_secure_password 130 | 131 | generates_token_for :password_reset, expires_in: 15.minutes do 132 | # `password_salt` (defined by `has_secure_password`) returns the salt for 133 | # the password. The salt changes when the password is changed, so the token 134 | # will expire when the password is changed. 135 | password_salt&.last(10) 136 | end 137 | end 138 | 139 | user = User.first 140 | token = user.generate_token_for(:password_reset) 141 | 142 | User.find_by_token_for(:password_reset, token) # => user 143 | 144 | user.update!(password: "new password") 145 | User.find_by_token_for(:password_reset, token) # => nil 146 | ``` 147 | 148 | - Add `perform_all_later` to enqueue multiple jobs at once 149 | 150 | ```ruby 151 | # Enqueueing individual jobs 152 | ActiveJob.perform_all_later(MyJob.new("hello", 42), MyJob.new("world", 0)) 153 | 154 | # Enqueueing an array of jobs 155 | user_jobs = User.pluck(:id).map { |id| UserJob.new(user_id: id) } 156 | ActiveJob.perform_all_later(user_jobs) 157 | ``` 158 | 159 | - Support "Composite primary keys" at both the database and application level. This feature is particularly beneficial for many-to-many relationships and other complex data models where a single column is insufficient to uniquely identify a record. 160 | 161 | ```ruby 162 | class TravelRoute < ActiveRecord::Base 163 | query_constraints :origin, :destination 164 | end 165 | 166 | 167 | class TravelRouteReview < ActiveRecord::Base 168 | belongs_to :travel_route, query_constraints: [:travel_route_origin, :travel_route_destination] 169 | end 170 | ``` 171 | 172 | - Introduce adapter for `Trilogy` for MySQL 173 | 174 | ```yml 175 | # database.yml config 176 | development: 177 | adapter: trilogy 178 | database: blog_development 179 | pool: 5 180 | ``` 181 | 182 | - Add `ActiveSupport::MessagePack` - a serializer that integrates with the `msgpack` gem. 183 | 184 | ```ruby 185 | ## Can be used as a message serializer ## 186 | # Globally 187 | config.active_support.message_serializer = :message_pack 188 | 189 | # Or individually: 190 | ActiveSupport::MessageEncryptor.new(secret, serializer: :message_pack) 191 | ActiveSupport::MessageVerifier.new(secret, serializer: :message_pack) 192 | ``` 193 | 194 | ```ruby 195 | ## Cookies serializer ## 196 | # Globally 197 | config.action_dispatch.cookies_serializer = :message_pack 198 | ``` 199 | 200 | ```ruby 201 | ## Cache serializer ## 202 | # Globally 203 | config.cache_store = :file_store, "tmp/cache", { serializer: :message_pack } 204 | 205 | # Or individually: 206 | ActiveSupport::Cache.lookup_store(:file_store, "tmp/cache", serializer: :message_pack) 207 | ``` 208 | 209 | - Introducing `config.autoload_lib` and `config.autoload_lib_once` for Enhanced Autoloading. 210 | This method is used to enhance the autoload paths of applications by including the lib directory, which is not included by default. Also, `config.autoload_lib(ignore: %w(assets tasks))` is generated for new applications. 211 | 212 | - Active Record API for general async queries (BIG BOOM!!) - A significant enhancement has been introduced to the Active Record API, expanding its support for asynchronous queries [Readmore](https://github.com/rails/rails/pull/44446) 213 | - Testing mode 214 | - Support pattern matching for JSON response.parsed_body 215 | - Extend response.parsed_body to parse HTML with Nokogiri 216 | 217 | ### 7.2 (August 2024) 218 | 219 | - Require Ruby 3.1 or later 220 | - Support "Development containers" configuration 221 | - Add browser version guard by default - adds the ability to specify the browser versions that will be allowed to access all actions 222 | 223 | ```ruby 224 | class ApplicationController < ActionController::Base 225 | # Allow only browsers natively supporting webp images, web push, badges, import maps, CSS nesting + :has 226 | allow_browser versions: :modern 227 | end 228 | 229 | class ApplicationController < ActionController::Base 230 | # All versions of Chrome and Opera will be allowed, but no versions of "internet explorer" (ie). Safari needs to be 16.4+ and Firefox 121+. 231 | allow_browser versions: { safari: 16.4, firefox: 121, ie: false } 232 | end 233 | 234 | class MessagesController < ApplicationController 235 | # In addition to the browsers blocked by ApplicationController, also block Opera below 104 and Chrome below 119 for the show action. 236 | allow_browser versions: { opera: 104, chrome: 119 }, only: :show 237 | end 238 | ``` 239 | 240 | - Default Progressive Web Application (PWA) files - New directory for PWA `app/views/pwa` 241 | - Add "omakase RuboCop" rules by default [Read More](https://github.com/rails/rubocop-rails-omakase) 242 | - Add GitHub CI workflow by default to new applications 243 | - Add Brakeman by default to new applications 244 | - Set a new default for the Puma thread count - from 5 => 3 245 | - Prevent jobs from being scheduled within transactions. 246 | A common mistake with Active Job is to enqueue jobs from inside a transaction, causing them to potentially be picked and ran by another process, before the transaction is committed, which result in various errors. 247 | 248 | ```ruby 249 | Topic.transaction do 250 | topic = Topic.create 251 | 252 | NewTopicNotificationJob.perform_later(topic) 253 | end 254 | 255 | class NewTopicNotificationJob < ApplicationJob 256 | self.enqueue_after_transaction_commit = :never 257 | end 258 | ``` 259 | 260 | - Support Per transaction commit and rollback callbacks 261 | 262 | ```ruby 263 | Article.transaction do |transaction| 264 | article.update(published: true) 265 | 266 | transaction.after_commit do 267 | PublishNotificationMailer.with(article: article).deliver_later 268 | end 269 | end 270 | 271 | # ActiveRecord::Base.current_transaction was also added to allow to register callbacks on it. 272 | Article.current_transaction.after_commit do 273 | PublishNotificationMailer.with(article: article).deliver_later 274 | end 275 | 276 | # for code that may run either inside or outside a transaction and needs to perform work after the state changes have been properly persisted. 277 | def publish_article(article) 278 | article.update(published: true) 279 | 280 | ActiveRecord.after_all_transactions_commit do 281 | PublishNotificationMailer.with(article: article).deliver_later 282 | end 283 | end 284 | ``` 285 | 286 | - Enable YJIT by default if running Ruby 3.3+ - It can provide significant performance improvements for Rails applications, offering **15-25%** latency improvements. 287 | - Setup `jemalloc` in default Dockerfile to optimize memory allocation [Read More](https://www.speedshop.co/2017/12/04/malloc-doubles-ruby-memory.html) 288 | - Support `ActiveRecord::Base.connection_pool.with_connection` to we can return database connection in a block (instead of a request like normal) [Read More](https://github.com/rails/rails/pull/51349) 289 | 290 | ## Rails 8 291 | -------------------------------------------------------------------------------- /5_documents/arel_doc.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/5_documents/arel_doc.md -------------------------------------------------------------------------------- /6_books/Rails - Component Based Rails-Applications.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Rails - Component Based Rails-Applications.pdf -------------------------------------------------------------------------------- /6_books/Rails - Lean Publishing Growing Rails Applications in Practice (2014).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Rails - Lean Publishing Growing Rails Applications in Practice (2014).pdf -------------------------------------------------------------------------------- /6_books/Rails - Learn Rails 5-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Rails - Learn Rails 5-2.pdf -------------------------------------------------------------------------------- /6_books/Rails - Modular Rails The Complete Guide to Modular Rails Applications.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Rails - Modular Rails The Complete Guide to Modular Rails Applications.pdf -------------------------------------------------------------------------------- /6_books/Rails - Rails 5 Test Prescriptions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Rails - Rails 5 Test Prescriptions.pdf -------------------------------------------------------------------------------- /6_books/Rails - Service-Oriented Design with Ruby and Rails.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Rails - Service-Oriented Design with Ruby and Rails.pdf -------------------------------------------------------------------------------- /6_books/Ruby - Design Patterns in Ruby (2007).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Ruby - Design Patterns in Ruby (2007).pdf -------------------------------------------------------------------------------- /6_books/Ruby - Metaprogramming Ruby 2nd.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Ruby - Metaprogramming Ruby 2nd.pdf -------------------------------------------------------------------------------- /6_books/Ruby - Practical Object-Oriented Design - 2nd.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Ruby - Practical Object-Oriented Design - 2nd.pdf -------------------------------------------------------------------------------- /6_books/Ruby - Refactoring Ruby.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Ruby - Refactoring Ruby.pdf -------------------------------------------------------------------------------- /6_books/Ruby - Ruby Best Practices.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Ruby - Ruby Best Practices.pdf -------------------------------------------------------------------------------- /6_books/Ruby - Ruby Performance Optimization.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Ruby - Ruby Performance Optimization.pdf -------------------------------------------------------------------------------- /6_books/Ruby - Ruby Under a Microscope.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Ruby - Ruby Under a Microscope.pdf -------------------------------------------------------------------------------- /6_books/Ruby - Test Driven Development in Ruby.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Ruby - Test Driven Development in Ruby.pdf -------------------------------------------------------------------------------- /6_books/Ruby - Well grounded Rubyist - 3rd.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackie-do/ruby_and_rails_knowledge/aaf261799c56e504b4a7737f13e51b6e075a7496/6_books/Ruby - Well grounded Rubyist - 3rd.pdf -------------------------------------------------------------------------------- /7_gems/useful_gems.md: -------------------------------------------------------------------------------- 1 | # Useful Gem List 2 | 3 | ## 1. Optimizations (Database, Memory...) 4 | 5 | * `newrelic_rpm`- It provides you with deep information about the performance of your Rails or Ruby application as it runs in production and transmits 6 | * `jsonapi-serializer` - serialization time is at least 25 times faster than Active Model Serializers 7 | * `ruby-jmeter` - This gem lets you write test plans for JMeter 8 | * `jemalloc` - Instant jemalloc injection into Ruby apps, for better performance and less memory. 9 | * `active_record_doctor` - Active Record Doctor helps to keep the database in a good shape 10 | * `lol_dba` - small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed 11 | * `rails-perftest` - Performance testing a Ruby on Rails application. 12 | * `ruby-prof` - It can help you track down methods that are either slow, allocate a large number of objects or allocate objects with high memory usage 13 | * `bullet` - The Bullet gem is designed to help you increase your application's performance by reducing the number of queries it makes. 14 | * [`meta_request`](https://github.com/dejan/rails_panel) - Provides insight to db/rendering/total times, parameter list, rendered views and more. 15 | * [`derailed_benchmarks`](https://github.com/zombocom/derailed_benchmarks) - A series of things you can use to benchmark a Rails or Ruby app. 16 | * [`benchmark-ips`](https://github.com/evanphx/benchmark-ips) - Benchmark - An iterations per second enhancement to Benchmark 17 | * [`benchmark-memory`](https://github.com/michaelherold/benchmark-memory) - Benchmark - a tool that helps you to benchmark the memory usage of different pieces of code 18 | 19 | ## 2. Server, Database, Architect, Coding Patterns 20 | 21 | * `apartment` - Apartment provides tools to help you deal with multiple tenants in your Rails application 22 | * `ffi` - Ruby-FFI is a gem for programmatically loading dynamically-linked native libraries, binding functions within them, and calling those functions from Ruby code. (Ruby work with C) 23 | * `paper_trail` - Track changes to your models, for auditing or versioning. See how a model looked at any stage in its lifecycle, revert it to any version, or restore it after it has been destroyed. 24 | * [`ransack`](https://github.com/activerecord-hackery/ransack) - Ransack enables the creation of both simple and advanced search forms for your Ruby on Rails application. 25 | * `ar-octopus` - Octopus is a better way to do Database Sharding in ActiveRecord. 26 | * [`squeel`](https://github.com/activerecord-hackery/squeel) - Squeel lets you write your Active Record queries with fewer strings, and more Ruby, by making the Arel awesomeness that lies beneath Active Record more accessible. 27 | * [`sequel`](https://github.com/jeremyevans/sequel) - Sequel is a simple, flexible, and powerful SQL database access toolkit for Ruby. 28 | * [`rom`](https://github.com/rom-rb/rom) - Ruby Object Mapper (rom-rb) is a data mapping and persistence toolkit for Ruby with the goal to provide powerful object mapping capabilities without limiting the full power of your database. 29 | * [`readthis`](https://github.com/sorentwo/readthis) - Readthis is a Redis backed cache client for Ruby 30 | * [`active_record_extended`](https://github.com/GeorgeKaraszi/ActiveRecordExtended) - Adds extended functionality to Activerecord Postgres implementation 31 | 32 | #### Coding Patterns 33 | 34 | * `interactor` - Apply Interactor for coding 35 | * `draper` - Apply Decorator for coding 36 | * `dry-transaction` - Apply DRY style by using transactions 37 | * `dry-validation` - Apply DRY style by using validations 38 | * `dry-initializer` - Support params and options 39 | * [`waterfall`](https://github.com/apneadiving/waterfall) - Chain ruby commands, and treat them like a flow, which provides a new approach to application control flow. 40 | * [`wisper`](https://github.com/krisleech/wisper) - A micro library providing Ruby objects with `Publish-Subscribe` capabilities 41 | * [`subroutine`](https://github.com/guideline-tech/subroutine) - An interface for creating feature-driven operations. 42 | 43 | #### Coding Support 44 | 45 | * [`hashie`](https://github.com/hashie/hashie) - Hashie is a growing collection of tools that extend Hashes and make them more useful. 46 | * [`active_hash`](https://github.com/zilkey/active_hash) - ActiveHash is a simple base class that allows you to use a ruby hash as a readonly datasource for an ActiveRecord-like model. 47 | 48 | ## 3. Security, Protect 49 | 50 | * [`rack-attack`](https://github.com/rack/rack-attack) - Rack middleware for blocking & throttling abusive requests 51 | 52 | ## 4. Paralllel and Concurrent Processing 53 | 54 | * `parallel` - Run any code in parallel Processes(use all CPUs) or Threads(speedup blocking operations). 55 | * `eventmachine` - EventMachine is an event-driven I/O and lightweight concurrency library for Ruby 56 | * `typhoeus` - Using native C library for making multiple HTTP request at sametime 57 | 58 | ## 5. Authentications and Authorizations 59 | 60 | * [`authlogic`](https://github.com/binarylogic/authlogic) - An unobtrusive ruby authentication library based on ActiveRecord. 61 | * `pundit` - Pundit provides a set of helpers which guide you in leveraging regular Ruby classes and object oriented design patterns to build a simple, robust and scaleable authorization system. 62 | * `devise_invitable` - It adds support to Devise for sending invitations by email (it requires to be authenticated) and accept the invitation setting the password. 63 | * `devise` - Devise is a flexible authentication solution for Rails based on Warden. 64 | * `devise_token_auth` - Simple, multi-client and secure token-based authentication for Rails. 65 | * `simple_token_authentication` - Token authentication with Devise. 66 | * `cancancan` - an authorization library for Ruby and Ruby on Rails which restricts what resources a given user is allowed to access. 67 | * `rolify` - Very simple Roles library without any authorization enforcement supporting scope on resource object. 68 | * `warden` - Warden is a Rack-based middleware, designed to provide a mechanism for authentication in Ruby web applications. 69 | * `mechanize` - used for automating interaction with websites. Mechanize automatically stores and sends cookies, follows redirects, and can follow links and submit forms. 70 | * `recaptcha` - This gem provides helper methods for the reCAPTCHA API. 71 | * [`devise_masquerade`](https://github.com/oivoodoo/devise_masquerade) - It's a utility library for enabling functionallity like login as button for admin. 72 | 73 | ## 6. Ruby Framework, CMS 74 | 75 | * `grape` - Grape is a REST-like API framework for Ruby. It's designed to run on Rack or complement existing web application frameworks such as Rails and Sinatra by providing a simple DSL to easily develop RESTful APIs. 76 | * [`hamani`](https://hanamirb.org/) - Ruby performance framework 77 | * `camaleon_cms` - Camaleon CMS is a dynamic and advanced content management system based on Ruby on Rails that adapts to your needs 78 | * `spina` - Spina is a CMS for Rails 5.2. This guide is designed for developers with experience using Ruby on Rails. 79 | * `administrate` - Administrate is a library for Rails apps that automatically generates admin dashboards. 80 | * `solidus` - A free, open-source ecommerce platform that gives you complete control over your store. 81 | 82 | ## 7. Testing 83 | 84 | * `capybara-screenshot` - Active Merchant is an extraction from the ecommerce system Shopify. Shopify's requirements for a simple and unified API to access dozens of different payment gateways with very different internal APIs was the chief principle in designing the library. 85 | * `vcr` - Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests. HELP TEST THIRD PARTY via HTTP CALL 86 | * `webmock` - Using with vrc. Library for stubbing and setting expectations on HTTP requests in Ruby. 87 | * `puma-ngrok-tunnel` - For Demo, A plugin for puma that'll start a ngrok tunnel to your rails server when puma starts. 88 | * `simplecov` - SimpleCov is a code coverage analysis tool for Ruby. The overall coverage results for your projects, including all types of tests, Cucumber features, etc 89 | * `rspec-rails` - brings the RSpec testing framework to Ruby on Rails as a drop-in alternative to its default testing framework, Minitest. 90 | * `fasterer` - Fasterer will suggest some speed improvements which you can check 91 | 92 | * `rswag-specs` - Rswag extends rspec-rails "request specs" with a Swagger-based DSL for describing and testing API operations 93 | 94 | * `rubocop` - xxx 95 | * `rubocop-performance` - xxx 96 | 97 | ## 8. Payment 98 | 99 | * `activemerchant` - Active Merchant is an extraction from the ecommerce system Shopify. Shopify's requirements for a simple and unified API to access dozens of different payment gateways with very different internal APIs was the chief principle in designing the library. 100 | * `money-rails` - This library provides integration of the money gem with Rails. 101 | * `stripe` - The Stripe Ruby library provides convenient access to the Stripe API from applications written in the Ruby language 102 | 103 | ## 9. Document 104 | 105 | * `rails-erd` - is a gem that allows you to easily generate a diagram based on your application's Active Record models. The diagram gives an overview of how your models are related. Having a diagram that describes your models is perfect documentation for your application. 106 | * `apipie-rails` - Apipie-rails is a DSL and Rails engine for documenting your RESTful API 107 | * `annotate` - Add a comment summarizing the current schema to the top or bottom (ActiveRecord models, Fixture files ...) 108 | * [`rswag`](https://github.com/rswag/rswag) - Define and generate Api Docs 109 | 110 | ## 10. Monitoring 111 | 112 | * [`active_record_doctor`](https://github.com/gregnavis/active_record_doctor) - helps to keep the database in a good shape 113 | * [`brakeman`](https://github.com/presidentbeef/brakeman) - Brakeman is a static analysis tool which checks Ruby on Rails applications for security vulnerabilities 114 | * [`bundler-audit`](https://github.com/rubysec/bundler-audit) - Check gems: vulnerable versions, insecure gem sources, Prints advisory information ... 115 | * [`dawnscanner`](https://github.com/thesp0nge/dawnscanner) - Dawnscanner is a source code scanner designed to review your ruby code for security issues 116 | * [`exception_notification`](https://github.com/smartinez87/exception_notification) - provides a set of notifiers for sending notifications when errors occur in a Rack/Rails application 117 | * [`ecs-logging-ruby`](https://github.com/elastic/ecs-logging-ruby) - Custom log ElasticSearch 118 | * [`oink`](https://github.com/noahd1/oink) - Rails plugin and log parser to help narrow down the source(s) of increased memory usage in rails applications. 119 | * `rubycritic` - RubyCritic is a gem that wraps around static analysis gems such as Reek, Flay and Flog to provide a quality report of your Ruby code. 120 | * [`health_check`](https://github.com/ianheggie/health_check) - Simple health check of Rails edge apps for use with Pingdom, NewRelic, EngineYard 121 | 122 | ## 11. Work with files 123 | 124 | * [`prawn`](https://github.com/prawnpdf/prawn) - PDF generator, Prawn is a pure Ruby PDF generation library that provides a lot of great functionality while trying to remain simple and reasonably performant 125 | 126 | * [`wicked_pdf`](https://github.com/mileszs/wicked_pdf) - PDF generator from HTML using **wkhtmltopdf** 127 | 128 | ## 12. Additional Features 129 | 130 | #### Background Jobs 131 | 132 | * [`sidekiq`](https://github.com/sidekiq/sidekiq) - Sidekiq uses threads to handle many jobs at the same time in the same process. It does not require Rails but will integrate tightly with Rails to make background processing dead simple. Using Redis DB 133 | * [`resque`](https://github.com/resque/resque) - Redis-backed library for creating background jobs, placing those jobs on multiple queues, and processing them later 134 | * [`good_job`](https://github.com/bensheldon/good_job) - GoodJob is a multithreaded, Postgres-based, ActiveJob backend for Ruby on Rails. 135 | * [`solid_queue`](https://github.com/rails/solid_queue) - Rails Offical DB-based queuing backend for Active Job, using database (MySQL >=8, PostgreSQL >= 9.5) 136 | 137 | #### Forums 138 | 139 | * `discourse` ![GitHub Repo stars](https://img.shields.io/github/stars/discourse/discourse?style=social) - Discourse is the online home for your community. We offer a 100% open source community platform to those who want complete control over how and where their site is run. 140 | 141 | #### Others 142 | 143 | * [`aasm`](https://github.com/aasm/aasm) - This package contains AASM, a library for adding finite state machines to Ruby classes. 144 | * [`acts_as_list`](https://github.com/brendon/acts_as_list) - This acts_as extension provides the capabilities for sorting and reordering a number of objects in a list. The class that has this specified needs to have a position column defined as an integer on the mapped database table. 145 | * [`caxlsx`](https://github.com/caxlsx/caxlsx) - Export Excel. 146 | * `carrierwave` - provides a simple and extremely flexible way to upload files from Ruby applications. It works well with Rack based web applications, such as Ruby on Rails. 147 | * `config` - Config helps you easily manage environment specific settings in an easy and usable manner. 148 | * [`counter_culture`](https://github.com/magnusvk/counter_culture) - Turbo-charged counter caches for your Rails app. Huge improvements over the Rails standard counter caches 149 | * `dotenv-rails` - Shim to load environment variables from .env into ENV in development. 150 | * `database_cleaner-mongoid` - Database cleaner for MongoID 151 | * [`discard`](https://github.com/jhawthorn/discard) - A simple ActiveRecord mixin to add conventions for flagging records as discarded (soft delete) 152 | 153 | * [`sanitize_email`](https://github.com/pboling/sanitize_email) - This gem allows you to override your mail delivery settings, globally or in a local context. It is like a Ruby encrusted condom for your email server, just in case it decides to have intercourse with other servers via sundry mail protocols. 154 | * `gretel` - Handle Breadcrumb in Ruby 155 | * [`js-routes`](https://github.com/railsware/js-routes) - Generates javascript file that defines all Rails named routes as javascript helpers 156 | * `net-sftp` - Net::SFTP is a pure-Ruby implementation of the SFTP protocol. 157 | * [`noticed`](https://github.com/excid3/noticed) - Currently, we support these notification delivery methods out of the box: Database, Email, ActionCable channels, Slack ... 158 | * `multipart-post` - Adds a streamy multipart form post capability to Net::HTTP. Also supports other methods besides POST 159 | * `paranoia` - Solf delete 160 | * [`redcarpet`](https://github.com/vmg/redcarpet) - Redcarpet is a Ruby library for Markdown processing that smells like butterflies and popcorn 161 | * `ruby-progressbar` - The ultimate text progress bar library for Ruby! 162 | * `rpush` - Rpush aims to be the de facto gem for sending push notifications in Ruby 163 | * [`seed-fu`](https://github.com/mbleigh/seed-fu) - Seed Fu is an attempt to once and for all solve the problem of inserting and maintaining seed data in a database 164 | * [`xray-rails`](https://github.com/brentd/xray-rails) - Detect Rails views in development 165 | * [`mobility`](https://github.com/shioyama/mobility) - Translate module, Mobility is a gem for storing and retrieving translations as attributes on a class 166 | * [`disco`](https://github.com/ankane/disco) - Recommendations for Ruby and Rails using collaborative filtering 167 | * [`predictor`](https://github.com/nyagato-00/predictor) - Fast and efficient recommendations and predictions using Ruby & Redis 168 | * [`ahoy`](https://github.com/ankane/ahoy) - Track visits and events in Ruby, JavaScript, and native apps. Data is stored in your database 169 | * [`anycable`](https://github.com/anycable/anycable) - AnyCable allows you to use any WebSocket server (written in any language) as a replacement for your Ruby server (such as Faye, Action Cable, etc). 170 | * [`store_model`](https://github.com/DmitryTsepelev/store_model) - StoreModel gem allows you to wrap JSON-backed DB columns with ActiveModel-like classes. 171 | * [`premailer-rails`](https://github.com/fphilipe/premailer-rails) - This gem is a drop in solution for styling HTML emails with CSS without having to do the hard work yourself. 172 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ruby and Rails knowledge 2 | 3 | ## I. Ruby 4 | 5 | ### 1. Web Frameworks 6 | 7 | - [Rails](https://rubyonrails.org/) - The most famost Ruby framework for building websites and web apps 8 | - [Major updates of Rails versions](https://github.com/jackie-do/ruby_and_rails_knowledge/blob/master/1_ruby_web_frameworks/rails/major_updates_of_rails_version.md) 9 | - Rails Components in Advances: 10 | - [Active Record Query](https://github.com/jackie-do/ruby_and_rails_knowledge/blob/master/1_ruby_web_frameworks/rails/active_record_query.md) 11 | - [Action Cable](https://github.com/jackie-do/ruby_and_rails_knowledge/blob/master/1_ruby_web_frameworks/rails/action_cable.md) 12 | - [Rails Engine](https://github.com/jackie-do/ruby_and_rails_knowledge/blob/master/1_ruby_web_frameworks/rails/action_cable.md) 13 | - [Hanami](https://guides.hanamirb.org/v2.0/introduction/getting-started/) - A new star, applied new theories for modern and performance Ruby framework 14 | - [Sinatra](https://sinatrarb.com/intro.html) - The simplest and lightest framework with more than 2k lines of code, support very basic features. 15 | - [Grape](https://github.com/ruby-grape/grape#what-is-grape) - Grape is a REST-like API framework for Ruby 16 | - [Karafka](https://github.com/karafka/karafka) - Karafka is a Ruby and Rails multi-threaded efficient Kafka processing framework 17 | 18 | ### 2. Coding and Best Practices 19 | 20 | - [Ruby Best Libraries/Tools](https://github.com/markets/awesome-ruby) 21 | - [Ruby Style Guide](https://github.com/rubocop/ruby-style-guide) 22 | - [Rails Style Guide](https://github.com/rubocop/rails-style-guide) 23 | 24 | ## II. Rails in details 25 | 26 | ### 1. Architectures [read details](https://github.com/jackie-do/ruby_and_rails_knowledge/blob/master/1_ruby_web_frameworks/rails/details/architectures.md) 27 | 28 | - DDD in rails 29 |
30 | Click me 31 | 32 | - DDD and Hexagonal Architecture with Rails 33 | 34 | 35 | - Refactoring with hexagonal Rail (with example) 36 | 37 | 38 | - Building Complex Domains in Rails (DDD with Rails) 39 | 40 | 41 | - Demo 42 |
43 | 44 | ### 2. Development and Maintain projects [read details](https://github.com/jackie-do/ruby_and_rails_knowledge/blob/master/1_ruby_web_frameworks/rails/details/development_and_maintain_projects.md) 45 | 46 | ### 3. Tools documents 47 | 48 | - Arel doc: 49 | 50 | ## III. Hanami in details 51 | 52 | ### 1. Architectures 53 | 54 | - Hanami in Microservices - 55 | 56 | ### 2. Development and Maintain projects 57 | 58 | ## IV. Interesting toys in Ruby world 59 | 60 | - A really high performance web server [Falcon](https://github.com/socketry/falcon) 61 | 62 | ## V. Useful Gem list 63 | 64 | - [Gem list](https://github.com/jackiedo91/ruby_and_rails_knowledge/blob/master/7_gems/useful_gems.md) 65 | 66 | ## VI. Books and Articles 67 | 68 | - **Ruby (Basic, Design Pattern, Refactor, Low Level...)** 69 | > - (Beginner) [Well Grounded Rubybist - 3rd] 70 | > - (Beginner - Middle) [Practical Object-Oriented Design - 2nd] 71 | > - (Beginner - Middle) [TDD in Ruby] 72 | > - (Beginner - Middle) [Ruby Best Practices] 73 | > - (Middle) [Design Patterns in Ruby(2007)] 74 | > - (Middle - Advance) [Refactoring Ruby] 75 | > - (Middle - Advance) [Metaprograming Ruby] 76 | > - (Advance) [Ruby Under a Microscope] 77 | > - (Advance) [Ruby Performance Optimization] 78 | 79 | - **Rails (Basic, Structure, Scalability...)** 80 | > - (Beginner) [Learn Rails 5.2] 81 | > - (Beginner) [Rails 5 Test Prescriptions] 82 | > - (Middle) [Modular Rails - The complete guide] 83 | > - (Middle) [Service-Oriented Design with Ruby on Rails] 84 | > - (Middle) [Component Based Rails Applications] 85 | > - (Advance) [Lean Publishing Growing Rails Applications in Practice] 86 | --------------------------------------------------------------------------------