MY RAILS PROJECT :: HOTELIFY

rails g resource Hotel name price:float free_wifi:string free_breakfast:string
# a migration in db/migrate/20210118041252_create_hotels

class CreateHotels < ActiveRecord::Migration[5.2]
def change
create_table :hotels do |t|
t.string :name
t.float :price
t.string :free_wifi
t.string :free_breakfast
t.timestamps
end
end
end
# a Hotel model in app/models/hotel.rbclass Hotel < ApplicationRecord
end
# a Hotel controller in app/controllers/hotels_controller.rbclass HotelsController < ApplicationController
end
# opens up all of the routes in config/routes.rbRails.application.routes.draw do
resources :hotels
end
validate :dublicate_attributes, on: :create
Scope Methods
Class Method

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store