Skip to content

Instantly share code, notes, and snippets.

@lizdenhup
Created October 29, 2016 16:38
Show Gist options
  • Save lizdenhup/d935e5a585a747b9caf51ba482b86f11 to your computer and use it in GitHub Desktop.
Save lizdenhup/d935e5a585a747b9caf51ba482b86f11 to your computer and use it in GitHub Desktop.
rails-amusement-park-v-000
class Attraction < ActiveRecord::Base
has_many :rides
has_many :users, through: :rides
validates_presence_of :name, :min_height, :nausea_rating, :happiness_rating, :tickets
end
class CreateAttractions < ActiveRecord::Migration
def change
create_table :attractions do |t|
t.string :name
t.integer :tickets
t.integer :nausea_rating
t.integer :happiness_rating
t.integer :min_height
end
end
end
class CreateRides < ActiveRecord::Migration
def change
create_table :rides do |t|
t.references :user, index: true
t.references :attraction, index: true
end
end
end
a
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :password_digest
t.integer :nausea
t.integer :happiness
t.integer :tickets
t.integer :height
end
end
end
class Ride < ActiveRecord::Base
belongs_to :attraction
belongs_to :user
end
class User < ActiveRecord::Base
has_many :rides
has_many :attractions, through: :rides
has_secure_password
validates_presence_of :name, :password, :happiness, :nausea, :height, :tickets
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment