Reader small image

You're reading from  From PHP to Ruby on Rails

Product typeBook
Published inDec 2023
Reading LevelBeginner
PublisherPackt
ISBN-139781804610091
Edition1st Edition
Languages
Right arrow
Author (1)
Bernard Pineda
Bernard Pineda
author image
Bernard Pineda

Bernard Pineda is a seasoned developer with 20 years of web development experience. Proficient in PHP, Ruby, Python, and other backend technologies, he has taught PHP and PHP-based frameworks through video courses on platforms like LinkedIn Learning. His extensive work with Ruby and Ruby on Rails, along with curiosity in frontend development and game development, bring a diverse perspective to this book. Currently working as a Site Reliability Engineer in Silicon Valley, Bernard is always seeking new adventures.
Read more about Bernard Pineda

Right arrow

Connecting to a database

So far, we’ve created a Person model and the migrations needed for the structure of our database. Now we are ready to connect to our database. But wait, we’ve already connected to a database! As previously stated, if we were able to run our migration successfully, it means that we did indeed connect to the SQLite database. Now let’s take a look at how Rails is configured to do this. Let’s examine our Gemfile, and in doing so, we’ll see the following line:

…
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
…

The preceding line installs the sqlite3 gem that allows Rails to communicate with a SQLite database. But wait, there’s more. If we open the app/config/database.yml file, we will also see some of the database settings for our project:

…
default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
From PHP to Ruby on Rails
Published in: Dec 2023Publisher: PacktISBN-13: 9781804610091

Author (1)

author image
Bernard Pineda

Bernard Pineda is a seasoned developer with 20 years of web development experience. Proficient in PHP, Ruby, Python, and other backend technologies, he has taught PHP and PHP-based frameworks through video courses on platforms like LinkedIn Learning. His extensive work with Ruby and Ruby on Rails, along with curiosity in frontend development and game development, bring a diverse perspective to this book. Currently working as a Site Reliability Engineer in Silicon Valley, Bernard is always seeking new adventures.
Read more about Bernard Pineda