<repo_name>Kylatingey97/Missionary_Moms<file_sep>/config/routes.rb
Rails.application.routes.draw do
  devise_for :users, path: '', path_names: { sign_in: 'login', sign_up: 'register' }
  resources :blogs do 
    member do
      get :toggle_status
    end
  end
  resources :products, except: [:show]
  get 'product/:id', to: 'products#show', as: 'product_show'

  get 'about', to: 'pages#about'
  get 'checkout', to: 'pages#checkout'

  root to: 'pages#home'
end
<file_sep>/app/controllers/products_controller.rb
class ProductsController < ApplicationController
  def index
    @products = Product.all
  end

  def new
    @product = Product.new
  end

  def create
    @product = Product.new(params.require(:product).permit(:title, :subtitle, :body))

    respond_to do |format|
      if @product.save
        format.html { redirect_to products_path, notice: 'Your product was successfully created.' }
      else
        format.html { render :new }
      end
    end
  end

  def edit
    @product = Product.find(params[:id])
  end 

  def update
    @product = Product.find(params[:id])

    respond_to do |format|
      if @product.update(params.require(:product).permit(:title, :subtitle, :body))
        format.html { redirect_to products_path, notice: 'Product was successfully updated.' }
      else
        format.html { render :edit }
      end
    end
  end

  def show
    @product = Product.find(params[:id])
  end

  def destroy
    # Perform the lookup
    @product = Product.find(params[:id])

    # Destroy/delete the record
    @product.destroy

    # Redirect
    respond_to do |format|
      format.html { redirect_to products_url, notice: 'Product was removed.' }
    end
  end

end
<file_sep>/app/models/product.rb
class Product < ApplicationRecord
  validates_presence_of :title, :body, :main_image, :thumb_image
  has_many :categories

  after_initialize :set_defaults

  def set_defaults
    self.main_image ||= "http://placehold.it/600x400"
    self.thumb_image ||= "http://placehold.it/350x200"
  end
end
<file_sep>/app/models/item.rb
class Item < ApplicationRecord
  validates_presence_of :title
  belongs_to :categories
end
