Skip to content

Instantly share code, notes, and snippets.

View Tolchi's full-sized avatar
💯
Happy Coding

SeHoon Park Tolchi

💯
Happy Coding
View GitHub Profile
@Tolchi
Tolchi / circle_ci_config.yml
Created May 18, 2023 00:09 — forked from nashirox/circle_ci_config.yml
CircleCI config for Rails 6 + Ruby 2.6 + Postgres + Redis
version: 2
jobs:
build:
working_directory: ~/my-app
docker:
- image: circleci/ruby:2.6.3-node-browsers
environment:
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
DATABASE_URL: postgres://postgres:password@localhost:5432/tech_cast_test
@Tolchi
Tolchi / setup.md
Created June 6, 2022 15:31 — forked from blocknotes/setup.md
ActiveAdmin Trix editor setup (tested with Rails 6.0.3.3)
  • Setup the Rails project with ActiveAdmin using Webpacker: rails g active_admin:install --use_webpacker
  • Setup Trix editor for ActiveAdmin:
    • Execute: bin/rails action_text:install
    • Add Javascript library to app/javascript/packs/active_admin.js:
require("trix")
require("@rails/actiontext")
  • Add style library to app/javascript/stylesheets/active_admin.scss:
@Tolchi
Tolchi / rails.rb
Created June 1, 2022 13:55 — forked from castwide/rails.rb
Enhance Rails Intellisense in Solargraph
# The following comments fill some of the gaps in Solargraph's understanding of
# Rails apps. Since they're all in YARD, they get mapped in Solargraph but
# ignored at runtime.
#
# You can put this file anywhere in the project, as long as it gets included in
# the workspace maps. It's recommended that you keep it in a standalone file
# instead of pasting it into an existing one.
#
# @!parse
# class ActionController::Base
@Tolchi
Tolchi / .editorconfig
Created May 30, 2022 13:52 — forked from phanviet/.editorconfig
editorconfig-rails
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@Tolchi
Tolchi / slider.html
Created March 22, 2022 18:51 — forked from DavidColby/slider.html
Implementation of a horizontal slider component with Stimulus and Tailwind CSS
<!--
This code is meant to accompany the guide originally published at https://colby.so/posts/building-a-horizontal-slider-with-stimulus-and-tailwind
It intentionally pulls in Tailwind CSS and Stimulus without a build system to simplify the guide. You shouldn't do this with a real application,
you should use a build system like webpack!
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
@Tolchi
Tolchi / README
Created August 12, 2020 19:45 — forked from jasper502/README
Devise with additional user fields, nested models / attributes and custom routes
The idea here is that I have a single User login that can eventually be tied to multiple Companies via the Role.
You signup via Devise on the custom /register route and fillout the Company information etc. The custom registration controller creates the Role during the user creation and sets a few other attributes.
It all worked but now it's broken and I have no idea what I did to break it.
When I try to create a new user / company the additional user fields (name_first & name_last) always fail validation regardless if they are in fact valid. The nested Company fields do not validate at all. If I enter the email and password field only the form works but only creates the User record.
To me it seems like the custom registration controller is not being processed at all.
@Tolchi
Tolchi / README
Created August 12, 2020 19:45 — forked from jasper502/README
Devise with additional user fields, nested models / attributes and custom routes
The idea here is that I have a single User login that can eventually be tied to multiple Companies via the Role.
You signup via Devise on the custom /register route and fillout the Company information etc. The custom registration controller creates the Role during the user creation and sets a few other attributes.
It all worked but now it's broken and I have no idea what I did to break it.
When I try to create a new user / company the additional user fields (name_first & name_last) always fail validation regardless if they are in fact valid. The nested Company fields do not validate at all. If I enter the email and password field only the form works but only creates the User record.
To me it seems like the custom registration controller is not being processed at all.
@Tolchi
Tolchi / heroku_pg_db_reset.md
Created June 16, 2020 18:06 — forked from zulhfreelancer/heroku_pg_db_reset.md
How to reset PG Database on Heroku?

How to reset PG Database on Heroku?

  • Step 1: heroku restart
  • Step 2: heroku pg:reset DATABASE (no need to change the DATABASE)
  • Step 3: heroku run rake db:migrate
  • Step 4: heroku run rake db:seed (if you have seed)

One liner

heroku restart; heroku pg:reset DATABASE --confirm APP-NAME; heroku run rake db:migrate

@Tolchi
Tolchi / reseed.rake
Created June 9, 2020 20:59 — forked from nithinbekal/reseed.rake
Rake task to reset and seed Rails database
# Originally written by Justin French (2008):
# http://justinfrench.com/notebook/a-custom-rake-task-to-reset-and-seed-your-database
#
# Modified to work with Rails 4.
desc 'Raise an error unless development environment'
task :safety_check do
raise "You can only use this in dev!" unless Rails.env.development?
end
@Tolchi
Tolchi / success_failure_blocks.rb
Created April 20, 2020 13:49 — forked from codespore/success_failure_blocks.rb
How to refactor controller actions using success or failure block
# app/controllers/posts_controller.rb
class PostsController < ApplicationController
def create
@post = Post.new(post_params)
CreatePost.call(@post) do |success, failure|
success.call { redirect_to posts_path, notice: 'Successfully created post.' }
failure.call { render :new }
end
end
end