Skip to content

Instantly share code, notes, and snippets.

View axtutuu's full-sized avatar
🦄
On vacation

Kawasaki Atsushi axtutuu

🦄
On vacation
View GitHub Profile
@axtutuu
axtutuu / hoge_model.rb
Last active October 5, 2016 06:42
マッチした attributes を配列で取り出す
class HogeModel
# fugaにマッチしたカラムの返却
def fuga_columns
self.attributes.keys.select { |a| a.match(/fuga/) }
end
end
@axtutuu
axtutuu / Gemfile.rb
Created October 5, 2016 01:41
New Relic Set Up on Ruby on Rails
gem 'newrelic_rpm'
@axtutuu
axtutuu / errors_controller.rb
Last active October 4, 2016 12:06
Ruby on Railsのエラーハンドリング
class ErrorsController < ActionController::Base
NOT_FOUND = 404
STANDARD_ERROR = 500
rescue_from StandardError, with: :error_500
rescue_from AbstractController::ActionNotFound, with: :render_404
rescue_from ActionController::RoutingError, with: :render_404
layout false
@axtutuu
axtutuu / model.rb
Last active October 3, 2016 02:52
ActiveRecordで取得したデータをカスタマイズしてJSONで返却
class Model < ActiveRecord::Base
has_many :users
def as_json(options={})
super.as_json(options).merge({users: self.users})
end
end
@axtutuu
axtutuu / 0_reuse_code.js
Created April 21, 2016 01:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console