Pre-Requisites
- I'll use Homebrew as the package manager.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Use
.zshrc
file if we have or if not just create it, by default we can use the vim editor
# To create the file
vim ~/.zshrc
# :w to save it.
Install Ruby
- Installing
rbenv
for ruby:
brew install rbenv ruby-build
- To use
rbenv
every time we create a new terminal session we set
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.zshrc
- Save the changes:
source ~/.zshrc
- Installing Ruby:
rbenv install 3.1.2
Note: The Ruby version can be found in the official Documentation
- Make Ruby's version as global:
rbenv global 3.1.2
- Save the changes:
source .zshrc
Note: To see if it was installed right we type:
ruby -v
Installing Rails
By installing ruby
we can use the gem
package manager, which contains rails
:
- Install Rails
gem install rails
- Reload
rbenv
to use the commandrails
rbenv rehash
Note: If we install rails
right, we can type:
rails -v
Create and run a new rails
project.
- Creating the project:
rails new proyect-name
Note: As default
rails
use theSQLite
database when a new project is created, we can use our own databases, such as MySQL, PostgreSQL, MongoDB, etc. And we can set it by typing:rails new proyect-name mysql
- Create a database for the project:
rails db:create
Note: If we a database with password, we have to configured the file
config/database.yml
, and change the data from the user (for developer purposesroot
) and the password. So by making saving this changes we use rails db:create
- Running the server:
rails server
Top comments (0)