Skip to content

Instantly share code, notes, and snippets.

class PostsController < ApplicationController
# GET /posts
# GET /posts.json
before_filter :authenticate_user!, only: [:new, :create, :edit, :destroy]
def index
if params[:options_for_active] == 'Show All'
@posts = Post.recent
.search_title_body(params[:search_by_title])
class Post < ActiveRecord::Base
attr_accessible :text, :title, :user_id, :category_id
validates :title, presence: true
validates :category_id, presence: true
validates_length_of :title, maximum:15
validates :text, presence:true
belongs_to :user
has_many :comments, :dependent => :destroy, foreign_key: :post_id
belongs_to :category
" PLUGINS
" vim-rails
" grep.vim
" nerdcommenter
" nerdtree
" snipmate.vim
" vim-fugitive
" vim-fuzzyfinder-pathogen
" vim-ragtag
" vim-surround
@choyno
choyno / toast.js
Last active August 29, 2015 14:08 — forked from kamranzafar/toast.js
var toast=function(msg){
$("<div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'><h3>"+msg+"</h3></div>")
.css({ display: "block",
opacity: 0.90,
position: "fixed",
padding: "7px",
"text-align": "center",
width: "270px",
left: ($(window).width() - 284)/2,
top: $(window).height()/2 })
""
"" Janus setup
""
" Define paths
let g:janus_path = escape(fnamemodify(resolve(expand("<sfile>:p")), ":h"), ' ')
let g:janus_vim_path = escape(fnamemodify(resolve(expand("<sfile>:p" . "vim")), ":h"), ' ')
let g:janus_custom_path = expand("~/.janus")
" Source janus's core
@choyno
choyno / self-signed-localhost-for-rails.txt
Created September 22, 2016 13:55 — forked from webdevotion/self-signed-localhost-for-rails.txt
SSL self signed localhost for rails start to finish, no red warnings.
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@choyno
choyno / Setup for Ruby on Rails development.md
Created June 22, 2017 03:45 — forked from fzrhrs/Setup for Ruby on Rails development.md
How to Install Xcode, Homebrew, Git, RVM, Ruby, Rails, Heroku Toolbelt and Postgres (Yosemite)

###Step 1: Install XCode

Check if the full Xcode package is already installed:

$ xcode-select -p

If you see:

/Applications/Xcode.app/Contents/Developer

@choyno
choyno / Setup for Ruby on Rails development.md
Created June 22, 2017 03:45 — forked from fzrhrs/Setup for Ruby on Rails development.md
How to Install Xcode, Homebrew, Git, RVM, Ruby, Rails, Heroku Toolbelt and Postgres (Yosemite)

###Step 1: Install XCode

Check if the full Xcode package is already installed:

$ xcode-select -p

If you see:

/Applications/Xcode.app/Contents/Developer

@choyno
choyno / gist:a699edc709d958ce8db532d77664417b
Created November 27, 2017 16:32 — forked from Atlas7/gist:d0c0680ae573a72e2d3d
Rails: Reinstall postgreSQL via brew ang pg gem on Mac OS X
$ brew uninstall postgresql
$ gem uninstall pg # ALL OF THEM
$ rm -fr /usr/local/var/postgres
$ launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
$ pg_ctl -D /usr/local/var/postgres stop -s -m fast # WE SHOULD HAVE ALL postgres SERVERS & PROCESSES STOPPED BY NOW
$ brew install postgres
$ env ARCHFLAGS="-arch x86_64" gem install pg
$ echo "DONE." >> /dev/null
@choyno
choyno / Rails New With Specific Rails Version
Last active May 15, 2020 02:36
Rails New With Specific Rails Version
# make directory for new rails app
mkdir app
cd app
# specify ruby version
echo 2.6.3 > .ruby-version
echo "source 'https://rubygems.org'" > Gemfile
echo "gem 'rails', '~> 6.1.0.alpha', git: 'https://github.com/Shopify/rails'" >> Gemfile
OR gem 'rails', '~> 6.1.0.alpha', git: 'https://github.com/Shopify/rails'