Skip to content

Instantly share code, notes, and snippets.

@voluntas
voluntas / webrtc.rst
Last active April 30, 2024 14:20
WebRTC コトハジメ
@iorionda
iorionda / to_factory_girl.rb
Created August 20, 2013 01:56
rails console で 3.2.11@1.9.3-p392(main)> model.first.to_fg
class ActiveRecord::Base
def to_factory_girl
ignores = %w(id created_at updated_at)
array = []
array << "FactoryGirl.define do"
array << " factory :#{self.class.model_name.underscore} do"
attributes.each do |key, value|
next if ignores.include?(key)
if key =~ /_id$/
array << " association :#{key.gsub(/_id$/, '')}"