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
module MyModel | |
extend ActiveSupport::Concern | |
included do | |
__send__(:include, ActiveModel::Conversion) | |
__send__(:include, ActiveModel::Validations) | |
extend ActiveModel::Naming | |
extend ActiveModel::Translation | |
class << self | |
alias_method_chain :i18n_scope, :my_model |
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
module MyModel | |
extend ActiveSupport::Concern | |
included do | |
__send__(:include, ActiveModel::Conversion) | |
__send__(:include, ActiveModel::Validations) | |
extend ActiveModel::Naming | |
extend ActiveModel::Translation | |
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
# xxx_create_tags.rb | |
class CreateTags < ActiveRecord::Migration | |
def change | |
create_table :tags do |t| | |
t.string :name, null: false | |
end | |
add_index :tags, :name, unique: true | |
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
# xxx_create_notes.rb | |
class CreateNotes< ActiveRecord::Migration | |
def change | |
create_table :notes do |t| | |
t.references :notable, polymorphic: true, null: false | |
t.text :note | |
end | |
add_index :notes, [:notable_type, :notable_id], unique: true | |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "centos65" | |
# HOSTから接続するため有効化 |
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 | |
# This script is deployed as /var/lib/rails/update_redmine.sh | |
if [ $# -eq 0 ]; then | |
echo Enter Redmine version. | |
exit 1 | |
fi | |
REDMINE_VERSION=$1 |
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
@user = User.new | |
# ========== 例外発生系 ========== | |
# 保存する | |
@user.save | |
# 保存に失敗したら例外を発生させる | |
@user.save! | |
# 更新する |
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
Pry::DEFAULT_HOOKS.add_hook(:before_session, :gem_auto_require) do |out, target, _pry_| | |
dir = `pwd`.chomp | |
gem_name = File.basename(dir) | |
if File.exist?(File.join(dir, "#{gem_name}.gemspec")) | |
lib = File.join(dir, 'lib') | |
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | |
if File.exist?(File.join(lib, "#{gem_name}.rb")) | |
begin | |
require gem_name | |
rescue LoadError => e |
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' | |
gem 'rails' | |
# some gems | |
group :development, :test do | |
gem 'rspec' | |
gem 'rspec-rails' | |
gem 'pry' |
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' | |
gem 'rails' | |
# some gems | |
group :development, :test do | |
gem 'rspec' | |
gem 'rspec-rails' |