Skip to content Skip to footer

All Posts

How To Use PostgreSQL In Rails
If you want to connect PostgreSQL In Rails, you first need to install the pg gem. You can do this by adding the following line to your Gemfile: gem 'pg' Then run bundle install from the command line to install the gem. Once the gem is installed, you can require it in your project. Example: require "pg" The pg gem defines…
Guide To Implement Rails Associations
Rails associations are a way to link one model to another. There are four different types of associations: One-to-one One-to-many Many-to-many Polymorphic Each type of association has its own set of methods that you can use to interact with the associated data. One-to-One Associations A one-to-one association means that each record in one…
How To Implement Cache In Rails
To implement a cache in Rails, you can use the ActiveSupport::Cache class. The ActiveSupport::Cache class provides a unified API for a variety of caching backends. For example: Memory store File store Dalli store You can use the ActiveSupport::Cache::Store#fetch method to read from the cache. If the data is not in the cache, the block you pass…