Skip to content

Instantly share code, notes, and snippets.

@4rlm
4rlm / rails_1_scaffold.txt
Last active September 14, 2018 14:19
Rails - 1. Scaffold
RUBY RVM
$ ruby -v
$ rvm install "ruby-2.4.2"
$ rbenv install 2.4.2
$ rbenv global 2.4.2
$ ruby -v
RUBY GEM VERSION
$ gem -v
$ gem update --system
@4rlm
4rlm / rails_2_gems.txt
Last active September 15, 2018 19:56
Rails - 2. Gems
## BOILER PLATE GEM FILE FOR MOST COMMON GEMS I USE ##
## COPY AND PASTE ENTIRE CONTENTS TO BOTTOM OF GEM FILE ##
## THEN COMMENT OUT OR DELETE GEMS NOT NEEDED ##
## THEN 'bundle install' THEN 'bundle update'
gem 'font-awesome-sass', '~> 5.0.6'
Use jquery as the JavaScript library
gem 'jquery-rails', '~> 4.3', '>= 4.3.1'
gem 'bootstrap', '~> 4.0.0'
gem 'autoprefixer-rails'
@4rlm
4rlm / rails_3_github.txt
Last active September 14, 2018 14:41
Rails - 3. Github
GITHUB CONFIGURATION STEPS
=============================================
* Create Git Hub Repo
$ git init
$ git add .
$ git commit -m "[Setup] first commit"
> Create new repo on GitHub site (Don't create Readme there.)
$ git remote add origin git@github.com:4rlm/eat_and_review.git
$ git push -u origin master
@4rlm
4rlm / rails_4_pipeline.txt
Last active September 14, 2018 14:47
Rails - 4. Asset Pipeline
RAILS ASSET PIPELINE CONFIGURATION STEPS
=============================================
Bootstrap Integration: https://launchschool.com/blog/integrating-rails-and-bootstrap-part-1
1. /app/assets/javascripts/application.js (keep same ordering as below.)
// = require jquery
// = require jquery_ujs
// = require rails-ujs
// = require turbolinks
// = require bootstrap-sprockets
@4rlm
4rlm / rails_ajax.txt
Created September 12, 2018 13:05
Rails - Axaj
Views NEEDED
_form.html.erb
_task.html.erb
create.js.erb
destroy.js.erb
index.html.erb
new.html.erb
new.js.erb
update.js.erb
========================
@4rlm
4rlm / rails_environment.txt
Created September 12, 2018 13:07
Rails - Environment Variables
API KEYS AND TOKENS VIA ENVIRONMENT VARIABLES
==========================
* Setup Secure ENV Variables for API Tokens/Access Keys
# config/application.rb
Bundler.require(*Rails.groups)
Dotenv::Railtie.load
# HOSTNAME = ENV['HOSTNAME']
GITHUB_ACCESS_TOKEN = ENV['GITHUB_ACCESS_TOKEN']
@4rlm
4rlm / rails_bcrypt.txt
Created September 12, 2018 13:17
Rails - Bcrypt
NOTE: ADD THESE NOTES BELOW TO ESSENTIAL RAILS IN github.
NOTE: BREAK THIS FILE INTO TWO SEPARATE ONES: 1) Polymorphic, 2) Bcrypt, 3) PG Dump-Restore
====================================
** ESSENTIAL RAILS....1) Polymorphic
====================================
1) g Track Scaffold:
1a) $ rails g model Track
@4rlm
4rlm / rails_heroku.txt
Last active September 13, 2018 23:44
Rails - Heroku
############ Adam Heroku Express! ############
$ heroku logs -t --app bds-max
$ heroku run rails c --app bds-max
$ heroku ps --app bds-max
$ heroku run rake db:migrate --app bds-max
$ heroku ps:restart --app bds-max
$ heroku config:set DB_POOL=10
@4rlm
4rlm / rails_safe_navigation_operators.txt
Created September 12, 2018 13:24
Rails - Safe Navigation Operators
# BLOG: http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/
# === Safe Navigation Operator === #
##########
## Scenario:
##########
if act && act.owner && act.owner.adr
...
end
@4rlm
4rlm / rails_json.txt
Created September 12, 2018 13:26
Rails - Json Builder
http://localhost:3000/artists.json
http://localhost:3000/activities.json
STEPS FOR CREATING JSON COMPATIBLE PARTIALS.
========== I. Data Flows in Order Listed ==========
---- A. HTML Rendering (3/5 pages) ----
1) show.html.erb
<%= render 'profiles/profile_partial', profile: @profile %>