View application.tailwind.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "tailwindcss/base"; | |
@import "tailwindcss/components"; | |
@import "./components/buttons.css"; | |
@import "./components/forms.css"; | |
@import "tailwindcss/utilities"; |
View notice.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% flash.each do |type, message| %> | |
<% if type == "alert" %> | |
<div class="bg-red-500"> | |
<div class="container px-2 mx-auto py-4 text-white text-center font-medium font-sans"> | |
<%= message %> | |
</div> | |
</div> | |
<% end %> | |
<% if type == "notice" %> | |
<div class="bg-green-500"> |
View routes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is for reference via the blog post/view at https://web-crunch.com/posts/ruby-on-rails-routing | |
require 'sidekiq/web' | |
Rails.application.routes.draw do | |
authenticate :user, lambda { |u| u.admin? } do # ensures authenticated users who are admins can only access anything within this block | |
mount Sidekiq::Web => '/sidekiq' # built into the sidekiq gem | |
end | |
devise_for :users # built into the Devise gem |
View validate_array_datatype.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the validator | |
# app/validators/array_validator.rb | |
class ArrayValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, values) | |
Array(values).each do |value| | |
options.each do |key, args| | |
validator_options = { attributes: attribute } | |
validator_options.merge!(args) if args.is_a?(Hash) |
View Gemfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
git_source(:github) do |repo_name| | |
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") | |
"https://github.com/#{repo_name}.git" | |
end | |
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' | |
gem 'rails', "5.2.3" |
View _form.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= simple_form_for @tweet do |f| %> | |
<%= f.error_notification %> | |
<div class="field"> | |
<div class="control"> | |
<%= f.input :tweets, label: "Tweeet about it", input_html: { class: "textarea"}, wrapper: false, label_html: {class: "label"}, placeholder: "Compose a new tweeet...", autofocus: true %> | |
</div> | |
</div> | |
<%= f.button :submit, class: "button is-info" %> | |
<% end %> |
View TweetsController.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TweetsController < ApplicationController | |
before_action :set_tweet, only: [:show, :edit, :update, :destroy] | |
# GET /tweets | |
# GET /tweets.json | |
def index | |
@tweets = Tweet.all.order("created_at DESC") | |
@tweet = Tweet.new | |
end |
View static-Gulpfile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var gulp = require('gulp'), | |
sass = require('gulp-sass'), | |
autoprefixer = require('gulp-autoprefixer'), | |
imagemin = require('gulp-imagemin'), | |
concat = require('gulp-concat'), | |
uglify = require('gulp-uglify'), | |
watch = require('gulp-watch'), | |
sourcemaps = require('gulp-sourcemaps'), |
View Gulpfile.js [Final]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Base Gulp File | |
var gulp = require('gulp'), | |
watch = require('gulp-watch'), | |
sass = require('gulp-sass'), | |
sourcemaps = require('gulp-sourcemaps'), | |
cssBase64 = require('gulp-css-base64'), | |
path = require('path'), | |
notify = require('gulp-notify'), | |
inlinesource = require('gulp-inline-source'), | |
browserSync = require('browser-sync'), |
View Gulpfile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var gulp = require('gulp'), | |
sass = require('gulp-sass'), | |
autoprefixer = require('gulp-autoprefixer'), | |
newer = require('gulp-newer'), | |
sourcemaps = require('gulp-sourcemaps'), | |
imagemin = require('gulp-imagemin'), | |
browserSync = require('browser-sync').create(), | |
reload = browserSync.reload, |
NewerOlder