If you would like to try Ruby on Rails 7 with Ruby 3 on Linuxmint 20.03, I am quickly going to demonstrate how to install Ruby, Node, NPM, Yarn, git, build essentials, Ruby on Rails 7 and all other required packages and also will create the demo Rails app and run the Rails server and pull up the rails app in my preferred web browser. There a screencast video of the process that you can find at bottom of the page.
Here is a quick approach to print pyramid patterns with Ruby Language. It’s a simple and easy approach that anyone can easily understand and try on their own. I am taking rows value in every for-in loop, but I have just mentioned once on the very first code block. I just updated the all the code blocks with gets method to take rows value from the user.
#1
print "Enter Number for Rows", ": "
rows = gets.chomp.to_i
for row in 0..rows
row.times {print "*"}
puts
end
*
**
***
****
*****
#2
print "Enter Number for Rows", ": "
rows = gets.chomp.to_i
for row in 0..rows
(rows-row).times {print "*"}
puts
end
*****
****
***
**
*
#3
print "Enter Number for Rows", ": "
rows = gets.chomp.to_i
for row in 0..rows
(rows-row).times {print " "}
row.times {print "*"}
puts
end
*
**
***
****
*****
#4
print "Enter Number for Rows", ": "
rows = gets.chomp.to_i
for row in 0..rows
row.times {print " "}
(rows-row).times {print "*"}
puts
end
*****
****
***
**
*
#5
print "Enter Number for Rows", ": "
rows = gets.chomp.to_i
for row in 0..rows
(rows-row).times {print " "}
row.times {print "*"}
(row-1).times {print "*" }
puts
end
*
***
*****
*******
*********
#6
print "Enter Number for Rows", ": "
rows = gets.chomp.to_i
for row in 0..rows
row.times {print " "}
(rows-row).times {print "*" }
(rows-row-1).times {print "*"}
puts
end
*********
*******
*****
***
*
#7
print "Enter Number for Rows", ": "
rows = gets.chomp.to_i
for row in 0..rows
(rows-row).times {print " "}
row.times {print "*"}
(row-1).times {print "*" }
puts
end
for row in 0..rows
row.times {print " "}
(rows-row).times {print "*" }
(rows-row-1).times {print "*"}
puts
end
Here is the code for all the patters mentioned above in one ruby file. If you would like, you can copy the code and run it on your system.
print "Enter Number for Rows", ": "
rows = gets.chomp.to_i
for row in 0..rows
row.times {print "*"}
puts
end
puts "-------------------"
# decreasing pattern
for row in 0..rows
(rows-row).times {print "*"}
puts
end
puts "-------------------"
for row in 0..rows
(rows-row).times {print " "}
row.times {print "*"}
puts
end
puts "-------------------------"
for row in 0..rows
row.times {print " "}
(rows-row).times {print "*"}
puts
end
puts '------------------------'
for row in 0..rows
(rows-row).times {print " "}
row.times {print "*"}
(row-1).times {print "*" }
puts
end
puts "=========================="
for row in 0..rows
row.times {print " "}
(rows-row).times {print "*" }
(rows-row-1).times {print "*"}
puts
end
# these two FOR loops run togather
for row in 0..rows
(rows-row).times {print " "}
row.times {print "*"}
(row-1).times {print "*" }
puts
end
for row in 0..rows
row.times {print " "}
(rows-row).times {print "*" }
(rows-row-1).times {print "*"}
puts
end
Make your ruby Gem install and Bundler update ruby gems like crazy fast with new commands. This will let you install rails and all other gems install without documentation. gem install rails –no-docs does not work.
Install Gem Without rdoc and ri
The old –no-rdoc and –no-ri have been merged into one –no-document
gem install rails --no-document
Create .gemrc file
Create .gemrc file in home directory and put the following commands and save the file.
install: --no-document
update: --no-document
or
gem: --no-document
Restart Terminal
After adding this command to .gemrc file, your gem install and bundle commands will not install rdoc and ri files for any gem you would install and this will make gem i and bundler update ruby gems like crazy fast.
On Linux
nano ~/.gemrc
nano will create .gemrc file in your home directory and now you’ll have to just write the following line and overwrite and save the file and restart the terminal.
gem: --no-document
On Windows 10
Just open your cmd and type open . create a file .gemrc in your user’s folder and type the same and save the file and restart the cmd.
Learn Ruby on Rails 6: This Rails 6 tutorial will help you create your very first app. You’ll learn the basic of Ruby on Rails 6 and once you have understood the basics of Ruby on Rails 6 – you would be on the way to creating your dream app.
Rails Action Text
Action Text add rich text editing experience to Rails app. It create a model call Rich Text, that can be associated to any existing model record and it exploits Active Storage to store its media data like images.
If Rails Action Text Does not show images
Behind the scenes rails uses imagemagick to style and manipulate images; make sure you already have installed imagemagick on your system before start using Active Storage and Action Text.
You can now install both Ruby 2.6 and DevKit together from rubyinstaller website. But if you only need ruby to be installed on your windows system, just download any ruby 2.x version from Ruby without DevKit download section.
https://rubyinstaller.org/downloads/
Download & Install DevKit on Windows
If you wish to install Ruby on Rails on Windows then you’ll require DevKit, which helps C-extensions compile immediately. Previously DevKit was downloaded and installed separately on Windows systems. Now, both ruby and DevKit can be installed together with just one click from rubyinstaller website.
To install Ruby on Rails, you need to install ruby with DevKit. Once your ruby is installed, check the ruby version with following command.
ruby -version
Install NodeJS and Yarn for Ruby on Rails
You’ll require Nodejs and Yarn to be installed before your start installing Rails 6.
Download & Install NodeJS
To install NodeJS, simply visit nodejs.org and download the latest or the stable version of Node and install it. With Node installation, you get nodejs, npm, and npx but yarn needs to be installed once you have nodejs installed on your system.
Install Yarn for Rails
npm i -g yarn
Let’s install Ruby on Rails 6
To install Ruby on Rails 6 without document. I do not prefer installing docs just because it takes time and space on the system.
gem install rails --no-document
It takes time. I know. After Rails is installed. Just create a demo app to test if Rails Development environment is set up properly.
rails new demoapp
cd demoapp
rails server
There is possibility that you’ll get errors, to fix errors scroll down. I have listed few common errors with solutions.
How to install ruby on windows 7, 8, and 10 computers and laptops. ruby installer for Windows users can download the ruby community recommended Ruby installer for windows and then run it and you are done.