Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Speaking via <code/>

AquisTech AquisTech

💻
Speaking via <code/>
View GitHub Profile
View rspec_cheatsheet_controller_spec.rb
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@AquisTech
AquisTech / rspec_model_testing_template.rb
Created Nov 17, 2020 — forked from kyletcarlson/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
View rspec_model_testing_template.rb
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@AquisTech
AquisTech / RAILS_CHEATSHEET.md
Created Nov 15, 2020 — forked from mdang/RAILS_CHEATSHEET.md
Ruby on Rails Cheatsheet
View RAILS_CHEATSHEET.md

Ruby on Rails Cheatsheet

Architecture

Create a new application

Install the Rails gem if you haven't done so before

@AquisTech
AquisTech / script.sh
Last active Sep 4, 2020 — forked from cheungnj/script.sh
Convert asciidoc to Github Flavored Markdown
View script.sh
# Adapted from https://tinyapps.org/blog/nix/201701240700_convert_asciidoc_to_markdown.html
# Using asciidoctor 1.5.6.1 and pandoc 2.0.0.1
# Install pandoc and asciidoctor
sudo apt install asciidoctor
sudo wget https://github.com/jgm/pandoc/releases/download/2.0.0.1/pandoc-2.0.0.1-1-amd64.deb
sudo dpkg -i pandoc-2.0.0.1-1-amd64.deb
# Convert asciidoc to docbook using asciidoctor
View solution.md

solution_link

If the following error occurs even though libc6-dev is installed,

Do you install glibc-devel(redhat) or libc6-dev(debian)?
You need /usr/include/sys/types.h to compile ruby-oci8.

You need to use ruby-oci8 2.1.0 or upper. Otherwise, run the following command and re-install ruby-oci8.

@AquisTech
AquisTech / test_queries.sql
Created Jul 17, 2018
WEEK OF MONTH function for MySQL to find week number in a month from date. #WEEKOFMONTH #WEEK_OF_MONTH
View test_queries.sql
SELECT '2018-07-1', WEEKOFMONTH('2018-07-1') AS week_of_month;
SELECT '2018-07-5', WEEKOFMONTH('2018-07-5') AS week_of_month;
SELECT '2018-07-7', WEEKOFMONTH('2018-07-7') AS week_of_month;
SELECT '2018-07-8', WEEKOFMONTH('2018-07-8') AS week_of_month;
SELECT '2018-07-10', WEEKOFMONTH('2018-07-10') AS week_of_month;
SELECT '2018-07-14', WEEKOFMONTH('2018-07-14') AS week_of_month;
SELECT '2018-07-15', WEEKOFMONTH('2018-07-15') AS week_of_month;
SELECT '2018-07-20', WEEKOFMONTH('2018-07-20') AS week_of_month;
@AquisTech
AquisTech / Scroll to top button
Last active Jul 11, 2018
Scroll to top button example
View Scroll to top button
Scroll to top button example
@AquisTech
AquisTech / serialized_store_example.md
Last active Oct 31, 2018
Store for serialized text column
View serialized_store_example.md
class User < ActiveRecord::Base
  store :settings, accessors: [ :color, :homepage ], coder: JSON
end

u = User.new(color: 'black', homepage: '37signals.com')
u.color                          # Accessor stored attribute
u.settings[:country] = 'Denmark' # Any attribute, even if not specified with an accessor

# There is no difference between strings and symbols for accessing custom attributes
@AquisTech
AquisTech / model_sequence.rb
Last active Nov 15, 2020
Order of elements arrangement in Model
View model_sequence.rb
# encoding
class ModelName < ApplicationRecord
# require statements
# extend Modules
# include Modules
# Gem/Plugins options
# CONSTANTS
# Attribute accessors
# serialize attributes
View gist:ff86995ccc0702ae9339a432bc3f1dbe
## API
* http://apionrails.icalialabs.com/book/chapter_one
* https://medium.com/statuscode/introducing-webpacker-7136d66cddfb#.9aou0hodw
* https://blog.codeship.com/building-a-json-api-with-rails-5/
* http://blog.arkency.com/2016/02/how-and-why-should-you-use-json-api-in-your-rails-api/
* https://github.com/tiagopog/jsonapi-utils
* https://robots.thoughtbot.com/validating-json-schemas-with-an-rspec-matcher
* https://github.com/interagent/heroics
* http://weblog.rubyonrails.org/2017/2/23/Rails-5-1-beta1/
* http://blog.michelada.io/whats-new-in-rails-51
You can’t perform that action at this time.