Created
July 30, 2020 19:37
-
-
Save stephepush/a96f2ab401109b6276dcdb4b53a55c7f to your computer and use it in GitHub Desktop.
Car dealer Backend Files
This file contains 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
#CarItem model | |
class CarItem < ApplicationRecord | |
belongs_to :model_info | |
end |
This file contains 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 CarItemsController < ApplicationController | |
def index | |
@CarItem = CarItem.all | |
render json: @CarItem | |
end | |
end |
This file contains 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
#ModelInfo model | |
class ModelInfo < ApplicationRecord | |
has_many :car_items | |
end |
This file contains 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 ModelInfosController < ApplicationController | |
def index | |
#get all the listings from the database | |
@ModelInfo = ModelInfo.all | |
render json: @ModelInfo | |
end | |
end |
This file contains 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
Rails.application.routes.draw do | |
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html | |
resources :model_infos, only: [:index] | |
resources :car_items, only: [:index, :show] | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment