Created
October 29, 2016 16:38
-
-
Save lizdenhup/d935e5a585a747b9caf51ba482b86f11 to your computer and use it in GitHub Desktop.
rails-amusement-park-v-000
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
class Attraction < ActiveRecord::Base | |
has_many :rides | |
has_many :users, through: :rides | |
validates_presence_of :name, :min_height, :nausea_rating, :happiness_rating, :tickets | |
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
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 |
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
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 |
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
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 |
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
class Ride < ActiveRecord::Base | |
belongs_to :attraction | |
belongs_to :user | |
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
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