Hello everyone.
Too tired for no reason today.
I did figure out the member routing for my custom controller action in my project. Will surely write on it in the next article, probably tomorrow.
Let's talk about RubyGems.
I am sure y'all have heard of gems before. If y'all didn't, it is a ruby packaging system used to create, install and share Ruby's libraries.
Great example is, Rails.
Y'all can create your own gems as well. It is easy. Before that, one of the best ways to master Ruby/Rails as suggested by many Ruby/Rails/Shopify Core Team Members is to read gems.
You can find the gem code in github but a better way would be to open it using bundler with your favourite text editor like VS Code.
In your terminal,
bundle open <gem-name>
This will open a new window with the whole gem unpacked in VS Code.
You can browse the gem-code by using the Search Bar in VS Code and follow actions & variables and learn how it works in the background.
You will be introduced to the most exciting awesomest feature of Ruby programming language:
Meta-programming is a technique by which you can write code that writes code by itself dynamically at runtime.
A simple example is,
rails g model Post title:string body:text
This is a simple model generator from Rails. By running the above command, Rails through the power of Ruby's meta-programming creates not only the model but everything necessary like controllers, views, helpers and many others I have no clue about to introduce Post into a full-stack web application.
Read about Ruby Meta-programming here:
Many thanks to the author.
Once you are familiar with Ruby Meta-Programming you can understand more of gems and it's working which ultimately leads to much better learning & understanding of Ruby on Rails.
Go ahead and try reading a gem.
Love,
M.
liked_the_post == true ? comment and share : comment and share