代码拉取完成,页面将自动刷新
rails generate scaffold api/User name:string password:string sex:string age:integer department:string avatar_url:string token:string admin:boolean
创建用户User资源,这一行动将会把一系列(Model、Controller、routes)资源全部都创建。seeds.rb
文件中填写初始的测试用户数据。rails db:migrate
迁移数据库,执行命令行rails db:seed
将初始数据存入数据库中。sqlite3 db/development.sqlite3
可以进入本项目的数据库,可以进行SQL语句的操作。schema.rb
文件
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_11_27_094203) do
# 帖子表
create_table "api_articles", force: :cascade do |t|
t.integer "author_id" # 作者id
t.string "title" # 标题
t.text "content" # 内容
t.string "tags" # 标签
t.integer "comment_num" # 评论数
t.integer "like_num" # 点赞数
t.integer "view_num" # 浏览数
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
# 一级评论表
create_table "api_comment_to_articles", force: :cascade do |t|
t.integer "article_id" # 被评论帖子id
t.integer "commentator_id" # 评论人id
t.text "content" # 内容
t.integer "child_num" # 二级评论数量
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
# 二级评论表
create_table "api_comment_to_comments", force: :cascade do |t|
t.integer "father_id" # 所属一级评论id
t.integer "commentator_id" # 评论人id
t.integer "ated_id" # 被评论人(被@的人)id
t.text "content" # 内容
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
# 通知记录
create_table "api_information", force: :cascade do |t|
t.integer "notifier" # 发起通知者id
t.integer "reciever_id" # 收到通知人id
t.integer "entity_id" # 被通知实体id(例如帖子被评论,被通知实体id就是帖子id)
t.integer "type" # 通知类型(帖子被评论1、帖子被点赞2、一级评论被评论3、二级评论被评论4)
t.boolean "status" # 通知状态(未读false、已读true)
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
# 点赞记录
create_table "api_like_records", force: :cascade do |t|
t.integer "article_id" # 帖子id
t.integer "creator_id" # 点赞人id
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
# 用户
create_table "api_users", force: :cascade do |t|
t.string "name" # 昵称
t.string "password" # 密码(前端md5加密后的密文)
t.string "sex" # 性别(男、女、秘密)
t.string "department" # 部门
t.string "avatar_url" # 头像的链接(云端存储头像图片)
t.string "token" # token(一个复杂的独一无二的字符串,只有http请求携带了正确的token,即视为登录状态)
t.boolean "admin" # 管理员(是true、否false)
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。