Well I got another error now with my database this time saying one of the classes I made "Parts" is not a class. I can't seem to know where this is tracing from
and here is my Parts database values (the file name is parts.rb)
class Parts < ActiveRecord::Migration
def change
create_table :parts do |t|
t.string :name
t.text :description
t.integer :category_id
end
end
end
my parts controller:
class PartsController < ApplicationController
before_filter :authorize, :except => :index
def index
@parts = Part.all
end
def new
@part = Part.new
end
def show
@part = Part.find(params[:id])
end
def create
@part = Part.new(part_params)
if @part.save
redirect_to part_path(@part)
end
end
def edit
@part = Part.find(params[:id])
end
def update
@part = Part.find(params[:id])
if @part.update_attributes(part_params)
redirect_to @part
end
end
def destroy
@part = Part.find(params[:id])
@part.destroy
redirect_to parts_path
end
private
def part_params
params.require(:part).permit(:description, :name)
end
end
my parts model is just
class Part < ActiveRecord::Base
end
Thanks for any help
Hope you generate the migration file with model by command like
bundle exec rails g model Part name:string description:text category_id:integer
it will create the migration file 2016...09_create_parts.rb
and it will be look like
def CreateParts < ActiveRecord::Migration
def change
create_table :parts do |t|
t.string :name
t.text :description
t.integer :category_id
end
end
end