Getting started Ruby on Rails 5

Generate a rails app:

rails new <app-name> -d <database>rails new test-app -d mysql (default:sqllite)

Basic Configurations:

If we make changes to Gemfile then run:

bundle install

App-level config:


# Application configuration should go into files in config/initializersi.e :config/initializers

DB-Configuration: (database.yml)

Query to create a database and user for a rails application.

CREATE DATABASE test-app_development;CREATE DATABASE test-app_test;GRANT ALL PRIVILEGES ON test-app_development.* To 'rails_user'@'localhost' IDENTIFIED By '<password>';GRANT ALL PRIVILEGES ON test-app_test.* To 'rails_user'@'localhost' IDENTIFIED By '<password>';
rails db:schema:dump

Model View Controller:

Model-View-Controller: In a real-life scenario, you can find this pattern very common. As in the cartoon below, is a representation of your favorite burger store. Where the counter manager acts as a Controller, who takes orders from the customer(Brower/Client) and then convey the request to the chef, who start cooking your delicious burger based on your preference. It is similar way controller sends the exchanges the data with the model which is required to display on your view. The Model will be your burger recipe which going to be the same for a respective type of client request. And finally, your controller will get the burger from the kitchen and serve it to the client i.e your View.

MVC: burger store
  • Assets: Images, CSS, javascript
  • Channels: Action Channels
  • Controllers
  • Helpers: View helpers
  • Jobs: Like Cron
  • Mailer: Sending emails
  • Model
  • Views

Start a Web-Server: for development (puma-server)

rails server or rails s
//issue with openssl gem install puma -- --with-opt-dir=/usr/local/bin/openssl (location of openssl installation)
rails g
rails generate controller BurgerController BurgerView

Routing :

Photo by Michał Parzuchowski on Unsplash
  • Simple
  • Default
  • Root
  • Resourceful (restful): for rest service
Rails.application.routes.draw doget 'burger_controller/BurgerView'# For details on the DSL available within this file, see
class BurgerControllerController < ApplicationControllerlayout falsedef BurgerView
@burgerList = ['Cheese-Burger', 'Bacon Burgers', 'Green-Chile Burgers']
<p>Find me in app/views/burger_controller/BurgerView.html.erb</p>
<% @burgerList.each do |n| %>
<%= n %> <br />
<% end %>
Burger View



#redhatter #opensource #developer #kubernetes #keycloak #golang #openshift #quarkus #spring

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store