Skip to content

Instantly share code, notes, and snippets.

View speratus's full-sized avatar
🚀
Always

Andrew Luchuk speratus

🚀
Always
View GitHub Profile
@speratus
speratus / cciar_act1_user.rb
Created December 5, 2019 14:07
Custom column names in ActiveRecord Act 1 User class
class User < ActiveRecord::Base
has_many :user_recipes
has_many :recipes, through: :user_recipes
end
@speratus
speratus / cciar_act1_recipe.rb
Created December 5, 2019 14:09
Custom column names in ActiveRecord Act 1 Recipe class
class Recipe < ActiveRecord::Base
has_many :user_recipes
has_many :users, through: :user_recipes
end
@speratus
speratus / cciar_act1_user_recipe.rb
Created December 5, 2019 14:10
Custom column names in ActiveRecord Act 1 UserRecipe join class
class UserRecipe < ActiveRecord::Base
belongs_to :user
belongs_to :recipe
end
@speratus
speratus / cciar_act2_user.rb
Created December 5, 2019 14:11
Custom column names in ActiveRecord Act 2 User class
class User < ActiveRecord::Base
has_many :user_recipes
has_many :recipes, through: :user_recipes
has_many :recipes
end
@speratus
speratus / cciar_act2_recipe.rb
Created December 5, 2019 14:12
Custom column names in ActiveRecord Act 2 Recipe class
class Recipe < ActiveRecord::Base
has_many :user_recipes
has_many :users, through: :user_recipes
belongs_to :user
end
@speratus
speratus / building-info application layout start.erb
Last active December 29, 2019 03:05
The most basic application layout generated courtesy of rails
<!DOCTYPE html>
<html>
<head>
<title>BuildingInfo</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
@speratus
speratus / building-info district index start.erb
Last active December 29, 2019 03:09
The most basic starting content for the districts index page
<h1>Districts</h1>
<ul>
<% @districts.each do |district| %>
<li>
<%= link_to district.name, district_path(district) %>
</li>
<% end %>
</ul>
@speratus
speratus / building-info district show start.erb
Last active December 29, 2019 03:17
The most basic show page for a district possible
<h1>
<%= @district.name %>
</h1>
<p>
<strong>Type: </strong><%= @district.district_type %>
</p>
<h3>Buildings</h3>
@speratus
speratus / building-info adding bulma to application layout.html
Created December 29, 2019 03:25
Adds Bulma stylesheet to the application layout
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/bulma@0.8.0/css/bulma.min.css">
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
@speratus
speratus / building-info adding navbar to application layout.erb
Created December 29, 2019 03:32
Adds the navbar to the application layout
...
<nav class="navbar">
<div class="navbar-menu">
<div class="navbar-start">
<%= link_to 'Districts', districts_path, class: "navbar-item" %>
<%= link_to 'Buildings', buildings_path, class: "navbar-item" %>
</div>
</div>
</nav>