RUBY ON RAILS Basics
Links
// RUBY ON RAILS
It's a framework, like react, it creates folders and files
MVC Architecture
Models: Databases
View: Webpages
Controller: The brains behind the scenes
// DIFFERENT FOLDERS CREATED TO USE
APP, CONFIG
Routes
Database
Gemfile
// GENERATE
rails g controller home index
erb = embeeded ruby
// RUN
From console: rails s
Localhost:3000 : Opens the web
Ctrl + C breaks
// To make a site as default for localhost:3000
Go to: Config routes.rb
comment: # get 'home/index'
add: root 'home#index'
// LAYOUTS
Go to folder views > layouts > application: This is the main template side <%=yield%>
// To create a new page
about.html.erb
controller
class HomeController < Application
def index
end
def about
end
end
route: go to config and
get 'home/about'
// BOotstrap
Starter template
Copy the template and add the meta or ruby thigs
// PARTIALS
Create a Navbar > create new file with this format:
_header.html.erb
Add in the page: <%= render 'home/header' %>
// LINKS
<%= link_to 'Friend App', root_path, class:"navbar-brand" %>
<%= link_to 'About Us', home_about_path, class:"nav-link" %> #
Check in console: rails routes, it tells you the different pages {name}_path
//
//
//