Commit d5c4efc5 authored by Chanelle Lunod's avatar Chanelle Lunod

Initial commit

parent 864ef5bf
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
// Place all the styles related to the Comments controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
class CommentsController < ApplicationController
def new
end
end
module CommentsHelper
end
class Comment < ApplicationRecord
belongs_to :user
belongs_to :post
end
<h1>Comments#new</h1>
<p>Find me in app/views/comments/new.html.erb</p>
......@@ -33,6 +33,9 @@
</td>
<td>
<%= time_ago_in_words(product.created_at) %> ago
</td>
<td>
<%= link_to "Add Comment", new_post_comment_path(post), class: "btn btn-info" %>
</td>
<td>
<%= link_to "Edit", edit_product_path(product), class: "btn btn-primary" %>
......
Rails.application.routes.draw do
get 'comments/new'
devise_for :admin_users
devise_scope :admin_user do
authenticated :admin_user do
......@@ -14,6 +15,7 @@ Rails.application.routes.draw do
resources :products, only: [] do
resources :orders, only: [:new, :create]
resources :supplies, only: [:new, :create]
resources :comments, only: [:new, :create]
end
root to: 'transactions#index', as: :authenticated_user_root
end
......
class CreateComments < ActiveRecord::Migration[5.2]
def change
create_table :comments do |t|
t.text :comment
t.references :user, foreign_key: true
t.references :post, foreign_key: true
t.timestamps
end
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2018_07_15_111200) do
ActiveRecord::Schema.define(version: 2018_07_16_132511) do
create_table "admin_users", force: :cascade do |t|
t.string "email", default: "", null: false
......@@ -29,6 +29,16 @@ ActiveRecord::Schema.define(version: 2018_07_15_111200) do
t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
end
create_table "comments", force: :cascade do |t|
t.text "comment"
t.integer "user_id"
t.integer "post_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["post_id"], name: "index_comments_on_post_id"
t.index ["user_id"], name: "index_comments_on_user_id"
end
create_table "products", force: :cascade do |t|
t.string "name"
t.text "description"
......
require 'test_helper'
class CommentsControllerTest < ActionDispatch::IntegrationTest
test "should get new" do
get comments_new_url
assert_response :success
end
end
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
comment: MyText
user: one
post: one
two:
comment: MyText
user: two
post: two
require 'test_helper'
class CommentTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment