Skip to content

Instantly share code, notes, and snippets.

@bigthyme
Last active December 11, 2015 06:38
Show Gist options
  • Save bigthyme/bba613569b946e390d5e to your computer and use it in GitHub Desktop.
Save bigthyme/bba613569b946e390d5e to your computer and use it in GitHub Desktop.
User.rb
class User < ActiveRecord::Base
validates :name, :uniqueness => true
attr_accessor :user_id, :name
has_many :favorites
has_many :teams, :through => :favorites
end
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.integer :user_id
t.string :name
t.timestamps
end
end
def self.down
drop_table :users
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment