This file contains hidden or 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
require 'thor' | |
class Gist < Thor | |
desc 'yo', 'gist sample task' | |
def yo | |
puts 'hey!' | |
end | |
end |
This file contains hidden or 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 ApplicationController < ActionController::Base | |
private | |
# ActionMailerのdefault_url_optionsを変更する | |
def set_default_url_options; ActionMailer::Base.default_url_options[:host] = request.host_with_port end | |
end | |
class UsersController < ApplicationController | |
before_action :set_user, only: [:show, :edit, :update, :destroy] | |
before_action :set_default_url_options, only: [:create, :update] | |
This file contains hidden or 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
require 'rails_helper' | |
RSpec.describe ApplicationFormBuilder do | |
describe '#select_genders' do | |
let(:user) { User.create(name: 'name', gender: 'male') } | |
let(:builder){ ApplicationFormBuilder.new :user, user, ActionView::Base.new, {} } | |
it { | |
expect(builder.select_genders).to eq '<select name="user[gender]" id="user_gender"><option selected="selected" value="male">male</option> |
This file contains hidden or 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 ApplicationFormBuilder < ActionView::Helpers::FormBuilder | |
def select_genders(options = {}, html_options = {}) | |
select :gender, [ [ 'male', 'male' ], [ 'fmale', 'fmale' ] ], options, html_options | |
end | |
end |
This file contains hidden or 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 Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or 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' | |
ruby '2.0.0' | |
gem 'grape' | |
gem 'newrelic-grape' | |
gem 'rails', '4.0.1' | |
gem 'newrelic_rpm' | |
gem 'unicorn' |
This file contains hidden or 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
#!/bin/sh | |
set -e | |
# Example init script, this can be used with nginx, too, | |
# since nginx and unicorn accept the same signals | |
# Feel free to change any of the following variables for your app: | |
TIMEOUT=${TIMEOUT-60} | |
APP_ROOT=/path/to/your/app/current | |
PID=$APP_ROOT/tmp/pids/unicorn.pid | |
ENVIRONMENT=production |
This file contains hidden or 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
puts "俺もgistデビューだ!" |