How to Use The Ruby Sequel Gem (With Examples)

What is Sequel? Sequel is a gem that allows you to access your database, no Rails required. You can connect to your database in different ways. Mostly two: By sending raw SQL commands By using an ORM Here’s an example, using raw SQL & the MySQL database. require ‘mysql2’ client = Mysql2::Client.new(host: “localhost”) results = … Read more

What Are Rails Parameters & How to Use Them Correctly

Let’s talk about Rails parameters! Why are they useful? Users can send data to your web application in three different ways. These three ways are: Using a query parameter (“example.com/?q=bacon”) Submitting a form (“/users/sign_in”) Within the URL itself (“/books/1”) How do you access this data from Rails? With params. Inside your controller action’s you can … Read more