Home
CrabCodes
Cancel

Authentication with Devise and cancancan in Rails

To use the cancancan gem with devise in a Ruby on Rails app, you will need to do the following: First, you need to add the cancancan gem to your Gemfile and run bundle install. Then create a Abil...

How to use an array field in a database table in Ruby on Rails

In Ruby on Rails, you can use an array field in a database table by defining it as a text data type and using the array: true option in your migration. For example, suppose you want to create a ta...

How to install Bootstrap and jQuery in Rails 7 app with importmap

First, add to your Gemfile gem 'jquery-rails' gem 'bootstrap' gem 'sassc-rails' And run bundle install Rename app/assets/stylesheets/application.css to app/assets/stylesheets/application.scss Th...

How to add tags to jekyll post on Github Pages

In this post, I will show you the way I’m using to add tags to jekyll post on Github Pages Add tags to posts In each post, you need to add tags to the header. Below is an example: --- layout: post...

Date format string cheat sheet in Ruby?

Date Formatting   %Y Year with century (e.g. 2022, 1982, etc) %m Month of the year, zero-padded (01..12) %B ...

How to instantiate class from string in Rails?

How to instantiate class from string in Rails? result_object = Object.const_get "ClassName" Below is an example how to instantiate class and call methods # ukraine.rb class Ukraine def say ...

Install iTerm2 and config oh-my-zsh on M1 MacOS 12 Monterey

What is iTerm2 iTerm2 is a replacement for Terminal that can do amazing things. To install iTerm2, it’s very easy # Terminal: Development brew install iterm2 If you did not install Homebrew yet...

How to install homebrew on M1 MacOS 12 Monterey

Today, I’ve just got new M1 Macbook Pro from my work. I have to re-setup my development envirnoment. So I noted my process here. What is Homebrew Homebrew is a package installer that helps us inst...

How to escape special characters in markdown

With previous post, I show you guys how to create blog site with jekyll and github pages. And when working on that post, I had some troubles with showing special characters in view. So this post wi...

Building Blog Website with Jekyll and Github pages

I created this blog by using Jekyll and Github Page. Jekyll is a gem that help you transform your plain text into static websites and blogs. Jekyll uses the Liquid templating language to process t...